Module logger
A simple logging module.
Description
This module can be used to log messages to the console.
Most applications should use the logging macros defined in logger.hrl to do logging.
Data Types
config()
config() = [config_item()]
config_item()
config_item() = {levels, [level()]}
level()
level() = debug | info | warning | error
location()
location() = {Module::module(), Function::atom(), Arity::non_neg_integer(), Line::non_neg_integer()}
sink()
sink() = {atom(), atom()}
Function Index
get_filter/0 | Get the current filter in the logger. |
get_levels/0 | Get the current levels in the logger. |
get_sinks/0 | Get the current sinks in the logger. |
log/3 | Log a message the the specified location with the specified level. |
set_filter/1 | Set the filter in the logger. |
set_levels/1 | Set the levels in the logger. |
set_sinks/1 | Set the sinks in the logger. |
start/0 | Start the logger. |
start/1 | Start the logger. |
stop/0 | Stop the logger. |
Function Details
get_filter/0
get_filter() -> {ok, Filter::[module()]} | {error, timeout}
returns: the current filter set in the logger
Get the current filter in the logger.
get_levels/0
get_levels() -> {ok, Levels::[level()]} | {error, timeout}
returns: the current list of levels set in the logger
Get the current levels in the logger.
get_sinks/0
get_sinks() -> {ok, Sinks::[sink()]} | {error, timeout}
returns: the current list of sinks set in the logger
Get the current sinks in the logger.
log/3
log(Location::location(), Level::level(), MsgFormat::{Format::string(), Args::[term()]}) -> ok
Location
: the location in the source moduleLevel
: the loglevelMsgFormat
: {String, [Args]} in io:format/1,2 notation.
Log a message the the specified location with the specified level.
Users should use the logging macros in logger.hrl instead of calling this function directly.
set_filter/1
set_filter(Filter::[module()]) -> ok
Filter
: the filter to set
returns: ok
Set the filter in the logger. Currently, a filter is a set of module names. If the filter is non-empty, then a log will be triggered only if the module being logged is in the filter list; otherwise, if the filter is empty, then the log will be triggered (if the level matches, as well)
set_levels/1
set_levels(Levels::[level()]) -> ok
Levels
: the list of levels to set
returns: ok
Set the levels in the logger.
set_sinks/1
set_sinks(Sinks::[sink()]) -> ok
Sinks
: the list of sinks to set
returns: ok
Set the sinks in the logger.
start/0
start() -> {ok, pid()}
Equivalent to start([{levels, [info, warning, error]}])
.
Start the logger.
start/1
start(Config::config()) -> {ok, pid()}
Config
: the logging configuration
returns: {ok, Pid}
Start the logger.
This function will start the logger with the specified configuration.
stop/0
stop() -> ok
Stop the logger.
This function is rarely used.