[ 
https://issues.apache.org/jira/browse/SPARK-15015?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15267310#comment-15267310
 ] 

John-Michael Reed commented on SPARK-15015:
-------------------------------------------

No runtime overhead. Compile time overhead. The compiler has to do a tiny
bit more work putting in the file name and line number into the source code
buffer. At runtime it's the same as if you took this:

    logger.warn("foo bar baz")

and replaced it with this:

    logger.warn("foo bar baz" + path.to.file(file.scala:33))

In my library, there is an environmental variable, "ENABLE_TRACE_DEBUG",
that you can set to "false" to make the compiler not look up the file
location and line number during compiler time. With the environment
variable set, the runtime code becomes:

    logger.warn("foo bar baz" + "")

Where instead of "path.to.file(file.scala:33)", the macro puts in an empty
string.

If you don't want to depend on an external JAR file, you can just
copy-paste this function:

https://github.com/JohnReedLOL/scala-trace-debug/blob/master/src/main/scala/scala/trace/Pos.scala

And get rid of " if (Printer.debugDisabled_?) { ... // return empty string
} " if you don't want the ENABLE_TRACE_DEBUG" environment variable.




> Log statements lack file name/number
> ------------------------------------
>
>                 Key: SPARK-15015
>                 URL: https://issues.apache.org/jira/browse/SPARK-15015
>             Project: Spark
>          Issue Type: Improvement
>          Components: Build
>    Affects Versions: 1.6.1
>         Environment: All
>            Reporter: John-Michael Reed
>            Priority: Trivial
>              Labels: debug, log
>
> I would like it if the Apache Spark project had file names and line numbers 
> in its log statements like this:
> http://i.imgur.com/4hvGQ0t.png
> The example uses my library, http://johnreedlol.github.io/scala-trace-debug/, 
> but https://github.com/lihaoyi/sourcecode is also useful for this purpose. 
> The real benefit in doing this is because the user of an IDE can jump to the 
> location of a log statement without having to set breakpoints.
> http://s29.postimg.org/ud0knou1j/debug_Screenshot_Crop.png
> Note that the arrow will go to the next log statement if each log statement 
> is hyperlinked.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to