Óg 


Óg is a small collection of logger helper functions.
Installation
Add óg to your list of dependencies in mix.exs:
def deps, do: [{:og, "~> 0.2"}]
Summary
log/1,log/2,log/3,log/4Inspects the data before logging it. For example, this can be helpful for avoiding the
Protocol.UndefinedErrorwhen logging tuples for example.Optionally pass the log_level
:debug,:info,:warnor:errorwhich will respect the logger:compile_time_purge_levelconfiguration setting - defaults to:debugwhen not passed.log_r/1,log_r/2Performs operations identical to
Og.log/4but returns the data in it's original form.Can be useful when one wants to log some intermediate data in the middle of a series of data transformations using the
|>operator.
Example Usages
Og.log/1
Og.log(String.to_atom("test"))Og.log/3
Og.log(String.to_atom("test"), __ENV__, :warn)Og.log/4
Og.log(:test, __ENV__, :info, inspect_opts: [syntax_colors: [atom: :blue]])
Og.log(String.to_atom("test"), :info, [pretty: :true, syntax_colors: [atom: :green]])Og.log_r/3
%{first: "john", last: "doe"}
|> Map.to_list()
|> Enum.filter( &(&1 === {:first, "john"}))
|> Og.log_r()
|> List.last()
|> Tuple.to_list()
|> List.last()
|> Og.log_r(:warn)
|> String.upcase()Acknowledgements
-
Thanks to Björn Rochel for the Apex library which is
used for pretty formatting the data in the
alogfunctions.
Licence
MIT