Reputation: 326
I want to beautify the logging of an Erlang project. Currently, it uses lager to log mostly integers. e.g:
lager:error("Failed with: ~p", [1]).
I'm trying to figure out if there is a way of specifying a module:function that will be called before the arguments are passed to lager? This function would convert the parameters from integers to more understandable values. Moreover, it would allow me to avoid manually changing all the calls to lager and pass them through a function such as:
lager:error("Failed with: ~p", beautify([1])).
Upvotes: 0
Views: 256
Reputation: 101
This is a easy but quite ugly solution:
-define(beauty_log(Level, Format, Args),
lager:Level(Format, amodule:beautify(Args))).
test() ->
?beauty_log(error, "Failed with: ~p", [1]).
Upvotes: 2