question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

macro to place logger in the companion

See original GitHub issue

Having a val log in every instance is extremely expensive… more so for lazy vals.

It would be much more efficient if the val lived on the companion and the log were a def that delegated.

To pull this off, one would have to implement this as a macro or compiler plugin.

Until then, I see no real benefit of using this library over say, akka’s Slf4jLogging trait, which already exists on most classpaths.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hseebergercommented, Apr 21, 2014

I see. But that’s indeed out of scope, because Scala Logging will only use blackbox macros.

1reaction
hseebergercommented, Apr 21, 2014

@fommil you don’t have to mix the StrictLogging (or LazyLogging) trait into your classes. If you want, you can simply create a Logger “manually” in a companion object and just use it from your companion classes.

Nevertheless I don’t think that mixing StrictLogging (or LazyLogging) into your classes creates too much overhead, because the logging framework will only create one logger instance per class name.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Macro to summon Mount + Companion - Wowhead
This is the macro I currently use to summon both mount and minipet: #showtooltip Fossilized Raptor /cast Fossilized Hatchling
Read more >
Best practices for loggers - Kotlin Discussions
Hi, What are best practices for creating loggers? I've seen: val log = LoggingFactory.getLogger("com.example.app"); but it would be nice to do something ...
Read more >
Basic debugging using logging for Swift and Objective-C apps.
This document talks about practical considerations about the NSLog function and the DEBUG preprocessor macro that are helpful for debugging.
Read more >
Location Macro — a useful Scala macro - Medium
The Scala compiler evaluates locationMacro at compile time for each place Location.capture is called. It extracts the name of a class and a...
Read more >
Meet KMO, a companion for your keyboard that acts as an ...
Meet KMO, a companion for your keyboard that acts as an input pass through and his own macro-pad! · There is a lot...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found