In the following PR, there are related discussions.
https://github.com/apache/spark/pull/332





------------------ Original ------------------
From:  "Marcelo Vanzin";<van...@cloudera.com>;
Date:  Fri, Apr 11, 2014 08:16 AM
To:  "dev"<dev@spark.apache.org>; 

Subject:  RFC: varargs in Logging.scala?



Hey there,

While going through the try to get the hang of things, I've noticed
several different styles of logging. They all have some downside
(readability being one of them in certain cases), but all of the
suffer from the fact that the log message needs to be built even
though it might not be used.

I spent some time trying to add varargs support to Logging.scala (also
to learn more about Scala itself), and came up with this:
https://github.com/vanzin/spark/commit/a15c284d4aac3d645b13c0ef157787ba014840e4

The change may look large, but the only interesting changes are in
Logging.scala, I promise.

What do you guys think of this approach?

It should, at worst, be just as fast (or slow) as before for the
majority of cases (i.e., any case where variables were used in the log
message). Personally, I think it reads better.

It might be possible to have something similar using string
interpolation, but I'm not familiar enough with Scala yet to try my
hand at that. Also, I believe that would still require some kind of
formatting when you want to do calculations (e.g. turn a variable
holding milliseconds into seconds in the log message).

If people like it, I'll submit a proper pull request. I've run a few
things using this code, and also the tests (which caught a few type
mismatches in the format strings), and everything looks ok so far.

-- 
Marcelo
.

Reply via email to