Hi folks
I’m working on a project where we want to replace lager
with OTP’s logger
and there is one thing that’s causing us quite a few headaches.
Since lager
uses parse-trasnforms, it can easily include module names, function names, line and column numbers, etc… in each log line, e.g. …
lager:debug("YOUR MESSAGE"),
ends up as…
2024-04-10 13:31:21.440 UTC [debug] <0.3338.0>@your_module:your_function:{26,5} YOUR MESSAGE
Now, we can manually do something like that with logger
…
logger:debug(
"YOUR MESSAGE",
[],
#{mfa => {?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY},
line => ?LINE
}).
But… we don’t want to repeat that map everywhere. We would also prefer not to put that map in a macro and repeat that macro everywhere. And we would also like not to use a parse transform for this.
Is there any other alternative to achieve the desired result that we’re not considering?
Thanks in advance.