logger
Module
Module Summary
Description
Data Types
emergency |
alert |
critical |
error |
warning |
notice |
info |
debug
The severity level for the message to be logged.
#{level => level(),
msg =>
{io:format(), [term()]} |
{report, report()} |
{string, unicode:chardata()},
meta => metadata()}
fun((term()) ->
{io:format(), [term()]} |
report() |
unicode:chardata())
Metadata associated with the message to be logged.
Macros
The following macros are defined:
- ?LOG_EMERGENCY(StringOrReport[,Metadata])
- ?LOG_EMERGENCY(FunOrFormat,Args[,Metadata])
- ?LOG_ALERT(StringOrReport[,Metadata])
- ?LOG_ALERT(FunOrFormat,Args[,Metadata])
- ?LOG_CRITICAL(StringOrReport[,Metadata])
- ?LOG_CRITICAL(FunOrFormat,Args[,Metadata])
- ?LOG_ERROR(StringOrReport[,Metadata])
- ?LOG_ERROR(FunOrFormat,Args[,Metadata])
- ?LOG_WARNING(StringOrReport[,Metadata])
- ?LOG_WARNING(FunOrFormat,Args[,Metadata])
- ?LOG_NOTICE(StringOrReport[,Metadata])
- ?LOG_NOTICE(FunOrFormat,Args[,Metadata])
- ?LOG_INFO(StringOrReport[,Metadata])
- ?LOG_INFO(FunOrFormat,Args[,Metadata])
- ?LOG_DEBUG(StringOrReport[,Metadata])
- ?LOG_DEBUG(FunOrFormat,Args[,Metadata])
All macros expand to a call to logger, where Level is taken from the macro name, and the following metadata is added, or merged with the given Metadata:
#{mfa=>{?MODULE,?FUNCTION_NAME,?FUNCTION_ARITY},
file=>?FILE,
line=>?LINE}The call is wrapped in a case statement and will be evaluated only if Level is equal to or below the configured log level.
Exports
emergency(StringOrReport[,Metadata])
emergency(Format,Args[,Metadata])
emergency(Fun,FunArgs[,Metadata])
Equivalent to log(emergency,...).
alert(StringOrReport[,Metadata])
alert(Format,Args[,Metadata])
alert(Fun,FunArgs[,Metadata])
Equivalent to log(alert,...).
critical(StringOrReport[,Metadata])
critical(Format,Args[,Metadata])
critical(Fun,FunArgs[,Metadata])
Equivalent to log(critical,...).
error(StringOrReport[,Metadata])
error(Format,Args[,Metadata])
error(Fun,FunArgs[,Metadata])
Equivalent to log(error,...).
warning(StringOrReport[,Metadata])
warning(Format,Args[,Metadata])
warning(Fun,FunArgs[,Metadata])
Equivalent to log(warning,...).
notice(StringOrReport[,Metadata])
notice(Format,Args[,Metadata])
notice(Fun,FunArgs[,Metadata])
Equivalent to log(notice,...).
info(StringOrReport[,Metadata])
info(Format,Args[,Metadata])
info(Fun,FunArgs[,Metadata])
Equivalent to log(info,...).
debug(StringOrReport[,Metadata])
debug(Format,Args[,Metadata])
debug(Fun,FunArgs[,Metadata])
Equivalent to log(debug,...).
Types
Log the given message.
Types
Lookup the current configuration for logger.
{ok, {Module, Config}} | {error, term()}
Lookup the current configuration for the given handler.
#{logger => config(),
handlers => [{handler_id(), module(), config()}],
module_levels => [{module(), level()}]}
Same as logger:i(term)
#{logger => config(),
handlers => [{handler_id(), module(), config()}],
module_levels => [{module(), level()}]}
The logger:i/1 function can be used to get all current logger configuration. The way that the information is returned depends on the Action
- string
- Return the pretty printed current logger configuration as iodata.
- term
- Return the current logger configuration as a term. The format of this term may change inbetween releases. For a stable format use logger:get_handler_config/1 and logger:get_logger_config/0. The same as calling logger:i().
- Pretty print all the current logger configuration to
standard out. Example:
1> logger:i(). Current logger configuration: Level: info FilterDefault: log Filters: Handlers: Id: logger_std_h Module: logger_std_h Level: info Formatter: Module: logger_formatter Config: #{template => [{logger_formatter,header},"\n",msg,"\n"], legacy_header => true} Filter Default: stop Filters: Id: stop_progress Fun: fun logger_filters:progress/2 Config: stop Id: remote_gl Fun: fun logger_filters:remote_gl/2 Config: stop Id: domain Fun: fun logger_filters:domain/2 Config: {log,prefix_of,[beam,erlang,otp,sasl]} Id: no_domain Fun: fun logger_filters:domain/2 Config: {log,no_domain,[]} Handler Config: logger_std_h: #{type => standard_io} Level set per module: Module: my_module Level: debug
Add a filter to the logger.
ok | {error, term()}
Add a filter to the specified handler.
Types
Remove the filter with the specified identity from the logger.
Remove the filter with the specified identity from the given handler.
Add a handler with the given configuration.
Types
Remove the handler with the specified identity.
Set the log level for the specified module.
To change the logging level globally, use logger:set_logger_config(level, Level).
Types
Remove a module specific log setting. After this, the global log level is used for the specified module.
Types
Add or update configuration data for the logger.
Add or update configuration data for the specified handler.
Compare the severity of two log levels. Returns gt if Level1 is more severe than Level2, lt if Level1 is less severe, and eq if the levels are equal.
Types
Set metadata which logger automatically inserts it in all log events produced on the current process. Subsequent calls will overwrite previous data set by this function.
When logging, location data produced by the log macros, and/or metadata given as argument to the log call (API function or macro), will be merged with the process metadata. If the same keys occur, values from the metadata argument to the log call will overwrite values in the process metadata, which in turn will overwrite values from the location data.
Types
Retrieve data set with set_process_metadata/1.
Delete data set with set_process_metadata/1.
