-
Notifications
You must be signed in to change notification settings - Fork 131
Context bound logger #212
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
Context bound logger #212
Conversation
… you don't want to pass it each time via implicit for every call, just set it once when you instantiate the logger. see lightbend-labs#208
… you don't want to pass it each time via implicit for every call, just set it once when you instantiate the logger. see lightbend-labs#208
Hi @grunzwei, Thank you for your contribution! We really value the time you've taken to put this together. Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement: |
sigh, no, this approach to extensibility with wrappers is no good, all the log messages will show incorrect log call site location :\ maybe you guys have another idea how the macros can inherit a trait ALogger, and later an abstract class can have a member |
I'm checking about the CLA thing with my workplace Wix, where this is an authorized side project. Will sign once i get instructions. |
i recreated the issue that's the original source or grief here, |
So, according to the answer in stackoverflow, there's no way of invoking an abstract type and getting the implementing macro. This leaves the approach i took of wrapping with an adapter ALogger and using it instead. I was concerned that this will lose call-site information for the logger, but from what i see, in scala, this isn't a big deal. Also, this makes me wonder... if callsite information is not the problem, why use macros to do the delayed logging based on log level? why not "pass by name" parameters?
no macros, still lazy... what am i missing? |
@Ophirr33 @eugeniyk @analytically - any chance you can take a look? |
so caller data is a thing in logback, for example, apparently : |
apparently not a big deal to configure, |
this PR has been a tale of woes in some parts.
first, it appears that you can't have a base class, for instance a trait ALogger, that is extended by both Logger and LoggerTakingArgInConstructor, which could be used in an abstract class that needs some logger, but doesn't know itself which logger should be used and needs it to be mixed in or inherited.
for some reason, once the abstract class member is of type ALogger, the macros are not invoked and you reach the default implementation of the ALogger trait.
sigh.
next, creating a trait ALogger and wrapping the macro loggers with it via delegation for the purposes mentioned above also fails - because putting a dependency from compiled code on macro requires separate compilation runs, and there is only one here.
sigh.
i had such hopes.
in this PR the ALogger trait is included but the wrappers allowing custom logger support are only in the test package as examples of how this could be achieved.
let's start talking about it ...