Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log with parameterized messages consistently for performance #1712

Closed
heuermh opened this issue Sep 6, 2017 · 5 comments · Fixed by #2136
Closed

Log with parameterized messages consistently for performance #1712

heuermh opened this issue Sep 6, 2017 · 5 comments · Fixed by #2136
Assignees
Milestone

Comments

@heuermh
Copy link
Member

heuermh commented Sep 6, 2017

Per https://www.slf4j.org/faq.html#logging_performance, logging with parameterized messages

log.info("message {} {}", one, two)

is preferable to alternatives found in our code base

log.info("message s% %s".format(one, two))

if (log.isInfoEnabled()) {
  log.info("message s% %s".format(one, two))
}

logInfo("message s% %s".format(one, two)")

See also mention in comment #1684 (comment)

@heuermh heuermh self-assigned this Sep 6, 2017
@fnothaft
Copy link
Member

fnothaft commented Sep 6, 2017

+1; also, perhaps everywhere that we've got a log.info(String) call, we can switch to logInfo?

@heuermh
Copy link
Member Author

heuermh commented Sep 6, 2017

+1; also, perhaps everywhere that we've got a log.info(String) call, we can switch to logInfo?

Yep, that is what I was thinking.

@fnothaft
Copy link
Member

fnothaft commented Sep 6, 2017

Sounds good!

@heuermh
Copy link
Member Author

heuermh commented Sep 11, 2017

Turns out the parameterized message methods in slf4j aren't so convenient to use from scala

[ERROR] adam/adam-core/src/main/scala/org/bdgenomics/adam/rdd/read/realignment/RealignIndels.scala:470:
error: ambiguous reference to overloaded definition,
[WARNING] both method warn in trait Logger of type (x$1: String, x$2: Any, x$3: Any)Unit
[WARNING] and  method warn in trait Logger of type (x$1: String, x$2: <repeated...>[Object])Unit
[INFO] match argument types (String,Option[(Int, org.bdgenomics.adam.rdd.read.realignment.IndelRealignmentTarget)],Throwable)
[WARNING]           log.warn("Realigning target {} failed with {}.", target, t)
[INFO]               ^

I think the best way forward is to commit to logInfo style and then refactor bdg-utils Logging to match and use slf4j parameterized message methods under the hood.

@heuermh
Copy link
Member Author

heuermh commented Nov 20, 2017

Note http://software.clapper.org/grizzled-slf4j/ might be of use.

@fnothaft fnothaft added this to the 0.25.0 milestone Mar 7, 2018
@heuermh heuermh modified the milestones: 0.26.0, 1.0.0 Jan 14, 2019
@heuermh heuermh modified the milestones: 1.0.0, 0.27.0 May 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants