Sorry if this has been asked before.
Is it possible to do something like:
config :logger, :console, format: “[$date][$time][$node][$level][$file][$function][$line] $message\n”
where the logger automatically puts in the function, line and file name?
for example, in C/C++ you can use the macros __ FILE __ and __ LINE __.
I mostly want to be lazy and cut and paste my:
Logger.warn “no pattern matched”
with adding the specifics.
The file, function and line are included in in the metadata, not the format. These are the acceptable format options:
The valid parameters you can use are:
$time - time the log message was sent
$date - date the log message was sent
$message - the log message
$level - the log level
$node - the node that prints the message
$metadata - user controlled data presented in “key=val key2=val2” format
$levelpad - sets to a single space if level is 4 characters long, otherwise set to the empty space. Used to align the message after level.
In addition to the keys provided by the user via Logger.metadata/1, the following extra keys are available to the :metadata list:
:application - the current application
:module - the current module
:function - the current function
:file - the current file
:line - the current line
:pid - the current process ID
config :logger, :console, format: "[$date][$time][$node][$level] $metadata$message\n"
metadata: [:file, :function, :line]
See here: Example of using Logger.metadata
that worked great.
I just had a drop in a comma after the: