Add -log-filter option to the zinc task

Review Request #2315 — Created June 3, 2015 and submitted

zundel
pants
zundel/zinc-add-log-filter
1612, 1631
6b00b1a...
pants-reviews
fkorotkov, stuhood

Add the -log-filter option to the zinc task to perform the same function as -Tnowarnregex for the Compiler class used under jmake

Tested by putting my updated zinc jar into place in BUILD.tools and updating pants.ini with:

+[compile.zinc-java]
+enabled: True
+
+args: [
+    '-fork-java',
+    '-log-filter', '.*X500.*',
+    '-java-only', '-C-encoding', '-CUTF-8',
+  ]

Then compiling the simple hello world target as modified in https://github.com/pantsbuild/pants/issues/1612. The lines containing the string X500 were omitted from the output.

  • 0
  • 0
  • 1
  • 0
  • 1
Description From Last Updated
JS
  1. 
      
  2. compile error - revert
  3. 
      
JS
  1. LGTM mod the revert bit noted above.
  2. This may be more idiomatic scala for succeed-fast, Stu will know:

    def isFiltered(message: => String): Boolean =
      filters.iterator.flatMap(_.findFirstIn(message)).isEmpty
    

    Where:
    + filters.iterator => ensure lazy / succeed fast behavior
    + flatMap => only include values extracted from Somes
    + _.findFirstIn(message) => apply the current Regex in the iteration
    + filters.iterator.flatMap(_.findFirstIn(message)) => an Iterator[String]

    1. Thanks for the detailed breakdown. I can see why Scala is an appealing language to write code in.

  3. 
      
ZU
ZU
  1. 
      
  2. One thing I could do differently is to accept a level as a separate part of the filter, but since the messages we care about seem to be logged with logRaw() I didn't see the point.

  3. 
      
FK
  1. 
      
  2. src/scala/org/pantsbuild/zinc/Util.scala (Diff revision 2)
     
     
     
     
     
     
     

    maybe

    filters.exists(_.findFirstIn(message).isDefined)

  3. 
      
ZU
ZU
Review request changed

Status: Closed (submitted)

Change Summary:

Thanks John & Fedor. Commit 4aa6204

ST
  1. 
      
  2. src/scala/org/pantsbuild/zinc/Util.scala (Diff revision 3)
     
     
     
     
     
     
     
     
     
     
     
     

    isFiltered being "by-name" will cause the message to be created multiple times if filters exist:
    once for each existing filter
    again if it is actually logged

    Would suggest creating a lazy val in the body of log and logRaw for the message so that it is only created once.

    1. Er, to be clear: the issue is that 'message' is by-name in multiple places.

  3. 
      
Loading...