Óg v0.2.0 Og
Some convenience utility functions on top of the elixir Logger module. Mostly useful for debugging purposes.
Summary
Inspects the data before logging it. For example, this can be helpful for avoiding the
Protocol.UndefinedErrorwhen logging tuples for example. There are two choices for formatting the data:Kernel.inspect/2(from erlang core)Apex.Format.format/2from Apex library for pretty printing
Configure the inspection function in the
config.exsfile by passing:config :logger, :og, default_inspector: Kernel.inspect/2
or
config :logger, :og, default_inspector: Apex.Format.format/2
Optionally pass the log_level
:debug,:info,:warnor:errorwhich will respect the logger:compile_time_purge_levelconfiguration setting. Defaults to:debug.Performs 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. see the example inlog_return/4.
Example configuration
- Short example:
use Mix.Config
config :logger,
backends: [:console],
level: :debug,
compile_time_purge_level: :debug,
compile_time_application: :my_app,
truncate: (4096 * 8),
utc_log: :false
config :logger, :console,
level: :debug,
format: "$time $metadata [$level] $message\n",
metadata: []
config :logger, :og,
default_inspector: &Kernel.inspect/2
- Long example:
use Mix.Config
limiter1 = "=================== [$level] ========================"
datetime = "|---$date $time"
metadata = "|---$metadata"
node = "|---$node"
msg = "|---message:"
limiter2 = "================== [end $level] ======================="
config :logger,
backends: [:console],
level: :debug,
compile_time_purge_level: :debug,
compile_time_application: :my_app,
truncate: (4096 * 8),
utc_log: :false
config :logger, :console,
level: :debug,
format: "#{limiter1}\n#{datetime}\n#{metadata}\n#{node}\n#{msg}\n\n$message\n\n#{limiter2}\n",
metadata: [:module, :function, :line]
config :logger, :og,
default_inspector: &Kernel.inspect/2,
kernel: [
inspect_opts: [width: 70]
],
apex: [
opts: [numbers: :false, color: :false]
]
Summary
Functions
Logs the data formatted with the Apex.Format.format/2 function and log_level :debug
Logs the data formatted with the Apex.Format.format/2 function and log_level passed as the second argument
Logs the data formatted with the Apex.Format.format/2 function and log_level :debug
Logs the data formatted with the Apex.Format.format/2 function and log_level passed as the second argument
Logs the data formatted with the Kernel.inspect/2 function and log_level :debug
Logs the data formatted with the Kernel.inspect/2 function and log_level passed as the second argument
Logs the data formatted with the Kernel.inspect/2 function and log_level :debug
Logs the data formatted with the Kernel.inspect/2 function and log_level passed as the second argument
Logs the data formatted with the default_inspector function and log_level :debug
Logs the data formatted with the default_inspector function and log_level passed as the second argument
Logs the data formatted with the default_inspector function and log_level passed as the second argument.
Returns the original data
Logs the data formatted with the default_inspector function and log_level :debug.
Returns the original data
Functions
Logs the data formatted with the Apex.Format.format/2 function and log_level :debug
Logs the data formatted with the Apex.Format.format/2 function and log_level passed as the second argument
Logs the data formatted with the Apex.Format.format/2 function and log_level :debug
Logs the data formatted with the Apex.Format.format/2 function and log_level passed as the second argument
Logs the data formatted with the Kernel.inspect/2 function and log_level :debug
Logs the data formatted with the Kernel.inspect/2 function and log_level passed as the second argument
Logs the data formatted with the Kernel.inspect/2 function and log_level :debug
Logs the data formatted with the Kernel.inspect/2 function and log_level passed as the second argument
Logs the data formatted with the default_inspector function and log_level :debug
Logs the data formatted with the default_inspector function and log_level passed as the second argument
Logs the data formatted with the default_inspector function and log_level passed as the second argument.
Returns the original data