parameterized logging?
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.
Do you know Log::Any? It is a log producer that can be bound to Log::Log4perl using Log::Any::Adapter::Log4perl.
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.