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

Way to change logger name #238

Open
cquiroz opened this issue Oct 2, 2019 · 4 comments
Open

Way to change logger name #238

cquiroz opened this issue Oct 2, 2019 · 4 comments

Comments

@cquiroz
Copy link
Contributor

cquiroz commented Oct 2, 2019

It would be nice for me to change the name of a passed Logger instance so I can differentiate across classes.

I think a method like
def withName(s: String): Logger[F]
would do

WDYT?

@ChristopherDavenport
Copy link
Member

These seems nice. Is anyone else sure how this translates to any backends other than slf4j?

@cquiroz
Copy link
Contributor Author

cquiroz commented Oct 17, 2019

Good question, I’ll try to prototype this in a PR

@satorg
Copy link

satorg commented Aug 9, 2023

I feel that the canonical way of dealing with logger names would be passing a LoggerFactory instance to class constructors instead of the Logger itself. Then, a new class-related instance of Logger is supposed to be created over there that would "latch" the class name per se.

The suggested withName method could be an alternative approach of course but to me it seems like a leaky abstraction a bit, because one class can be passed with Logger from another class and therefore start emit log messages on behalf of the other one.

@armanbilge
Copy link
Member

Yup, I think a LoggerFactory constraint is currently the best practice way to support logging. Or at least, that's what we did in http4s.

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

No branches or pull requests

4 participants