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

parameterized logging? #131

Open
burak opened this issue May 9, 2024 · 1 comment
Open

parameterized logging? #131

burak opened this issue May 9, 2024 · 1 comment

Comments

@burak
Copy link

burak commented May 9, 2024

Hi,

Short summary:

Instead of

DEBUG "Got here with " . $foo;

or even

DEBUG "Got here with " . Dumper $foo;

or even

DEBUG sprintf "Got here with %s", Dumper $foo;

It might be nicer to have a

DEBUG "Got here with {} and then {} and even {}", $foo, $bar, $baz;

This is actually a slf4j feature, but I think that it is quite a handy functionality to have (scroll down in the linked doc).

https://www.slf4j.org/faq.html#logging_performance

Implementation details:

https://github.com/qos-ch/slf4j/blob/master/slf4j-api/src/main/java/org/slf4j/helpers/MessageFormatter.java

The functionality boils down to replacing "{}" with the parameter list. It is akin to sprintf "%s" and for the reference parameters, Data::Dumper can be utilized as well.

@XSven
Copy link

XSven commented May 22, 2024

Do you know Log::Any? It is a log producer that can be bound to Log::Log4perl using Log::Any::Adapter::Log4perl.

Logging

There are also versions of each of the logging methods with an additional "f" suffix (infof, errorf, debugf, etc.) that format a list of arguments.

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

2 participants