From 8aa64c90ddd20ec0ca8cc5fe92a6124324c51da5 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 16 May 2018 16:10:30 +0200 Subject: Use system_time instead of monotonic_time as timestamp in logger --- lib/kernel/doc/src/logger.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/logger.xml b/lib/kernel/doc/src/logger.xml index 183102f240..cac9c39f2a 100644 --- a/lib/kernel/doc/src/logger.xml +++ b/lib/kernel/doc/src/logger.xml @@ -111,7 +111,7 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro pid => self() gl => group_leader() - time => erlang:monotonic_time(microsecond) + time => erlang:system_time(microsecond)

When a log macro is used, Logger also inserts location information:

@@ -184,8 +184,8 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro

A timestamp produced - with - erlang:monotonic_time(microsecond).

+ with + erlang:system_time(microsecond).

-- cgit v1.2.3 From a9a6b803a60793d42a74e0f1693a7594dffb6bc3 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Thu, 17 May 2018 18:19:57 +0200 Subject: Improve documentation of logger and error_logger --- lib/kernel/doc/src/error_logger.xml | 48 +++--- lib/kernel/doc/src/introduction_chapter.xml | 1 - lib/kernel/doc/src/kernel_app.xml | 11 +- lib/kernel/doc/src/logger.xml | 184 ++++++++++++++--------- lib/kernel/doc/src/logger_chapter.xml | 222 ++++++++++++++++------------ lib/kernel/doc/src/logger_disk_log_h.xml | 22 ++- lib/kernel/doc/src/logger_formatter.xml | 40 +++-- lib/kernel/doc/src/logger_std_h.xml | 19 ++- 8 files changed, 320 insertions(+), 227 deletions(-) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/error_logger.xml b/lib/kernel/doc/src/error_logger.xml index c9fe9484e4..e91fc734a4 100644 --- a/lib/kernel/doc/src/error_logger.xml +++ b/lib/kernel/doc/src/error_logger.xml @@ -36,41 +36,31 @@

In OTP-21, a new API for logging was added to Erlang/OTP. The old error_logger module can still be used by legacy code, but new code should use the new API instead.

+

error_logger is no longer started by default, but is + automatically started when an event handler is added + with error_logger:add_report_handler/1,2. The error_logger + module is then also added as a handler to the new logger.

See logger(3) and the Logging chapter - in the user's guide for more information.

+ in the User's Guide for more information.

The Erlang error logger is an event manager (see OTP Design Principles and gen_event(3)), - registered as error_logger. Errors, warnings, and info events - are sent to the error logger from the Erlang runtime system and - the different Erlang/OTP applications. The events are, by default, - logged to the terminal. Notice that an event from a process P is - logged at the node of the group leader of P. This means - that log output is directed to the node from which a process was - created, which not necessarily is the same node as where it is - executing.

-

Initially, error_logger has only a primitive event - handler, which buffers and prints the raw event messages. During - system startup, the Kernel application replaces this with a - standard event handler, by default one that writes - nicely formatted output to the terminal. Kernel can also be - configured so that events are logged to a file instead, or not logged at all, - see kernel(6).

-

Also the SASL application, if started, adds its own event - handler, which by default writes supervisor, crash, and progress - reports to the terminal. See - sasl(6).

-

It is recommended that user-defined applications report - errors through the error logger to get uniform reports. - User-defined event handlers can be added to handle application-specific - events, see - add_report_handler/1,2. - Also, a useful event handler is provided in STDLIB for multi-file - logging of events, see - log_mf_h(3).

+ registered as error_logger.

+

Error logger is no longer started by default, but is + automatically started when an event handler is added + with + add_report_handler/1,2. The error_logger + module is then also added as a handler to the new logger, + causing log events to be forwarded from logger to error logger, + and consequently to all installed error logger event + handlers.

+

User-defined event handlers can be added to handle application-specific + events.

+

Existing event handlers provided by STDLIB and SASL are still + available, but are no longer used by OTP.

Warning events were introduced in Erlang/OTP R9C and are enabled by default as from Erlang/OTP 18.0. To retain backwards compatibility with existing user-defined event handlers, the warning events can be @@ -191,7 +181,7 @@ ok

The error_logger_format_depth variable is deprecated since - the Logger API was + the logging API was introduced in OTP-21. The variable, and this function, are kept for backwards compatibility since they still might be used by legacy report handlers.

diff --git a/lib/kernel/doc/src/introduction_chapter.xml b/lib/kernel/doc/src/introduction_chapter.xml index 6e6990ddda..2eadc70abf 100644 --- a/lib/kernel/doc/src/introduction_chapter.xml +++ b/lib/kernel/doc/src/introduction_chapter.xml @@ -46,7 +46,6 @@ Start, stop, supervision, configuration, and distribution of applications Code loading Logging - Error logging Global name service Supervision of Erlang/OTP Communication with sockets diff --git a/lib/kernel/doc/src/kernel_app.xml b/lib/kernel/doc/src/kernel_app.xml index 7cd05dab14..5bc423afb6 100644 --- a/lib/kernel/doc/src/kernel_app.xml +++ b/lib/kernel/doc/src/kernel_app.xml @@ -42,7 +42,6 @@ Start, stop, supervision, configuration, and distribution of applications Code loading Logging - Error logging Global name service Supervision of Erlang/OTP Communication with sockets @@ -194,9 +193,9 @@ If the SASL application is started, these log events will be sent to a second handler instance named sasl_h, according to values of the SASL - environment variables sasl_error_logger + configuration parameter sasl_error_logger and sasl_errlog_type, see - SASL(6) + sasl(6)

The default value is false.

See chapter Backwards @@ -271,7 +270,7 @@ inet_parse_error_log = silent

If set, no - error_logger messages are generated when erroneous + logger messages are generated when erroneous lines are found and skipped in the various Inet configuration files.

@@ -486,7 +485,7 @@ MaxT = TickTime + TickTime / 4 old error_logger event manager, and event handlers running on this manager, will still work, but they are not used by default.

-

The following application environment variables can still be +

The following application configuration parameters can still be set, but they will only be used if the corresponding new logger variables are not set.

@@ -519,12 +518,12 @@ erl -kernel logger '[{handler,default,logger_std_h,#{formatter=>{logger_formatte disk_log(3), erl_boot_server(3), erl_ddll(3), - error_logger(3), file(3), global(3), global_group(3), heart(3), inet(3), + logger(3), net_kernel(3), os(3), pg2(3), diff --git a/lib/kernel/doc/src/logger.xml b/lib/kernel/doc/src/logger.xml index cac9c39f2a..f7e740e90d 100644 --- a/lib/kernel/doc/src/logger.xml +++ b/lib/kernel/doc/src/logger.xml @@ -33,23 +33,51 @@ logger.xml logger - API module for the logger. + API module for logging in Erlang/OTP. + + + + +

- This module is the main logger API. It contains functions that allow - application to use a single log API and the system to manage those log - events independently. To log events the logger - macros should be used. For instance, - to log a new error log event:

+ This module is the main API for logging in Erlang/OTP. It + contains functions that allow applications to use a single log + API and the system to manage those log events independently. Use + the API functions or the log + macros to log events. For instance, + to log a new error event:

?LOG_ERROR("error happened because: ~p",[Reason]). %% With macro logger:error("error happened because: ~p",[Reason]). %% Without macro -

This log event will then be sent to the configured log handlers which - by default means that it will be printed to the console. If you want +

This log event is then sent to the configured log handlers which + by default means that it is be printed to the console. If you want your systems logs to be printed to a file instead of the console you - have to configure the default handler to do so. The simplest way is + must configure the default handler to do so. The simplest way is to include the following in your sys.config.

[{kernel, @@ -63,7 +91,7 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro how to use the API, see the User's Guide. - how to configure logger, + how to configure Logger, see the Configuration section in the User's Guide. the convinience macros in logger.hrl, @@ -129,8 +157,8 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro update_process_metadata/1
.

Logger merges all the metadata maps before forwarding the log event to the handlers. If the same keys occur, values - from the log call overwrites process metadata, which in turn - overwrites values set by Logger.

+ from the log call overwrite process metadata, which in turn + overwrite values set by Logger.

@@ -165,7 +193,8 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro -

A filter which can be installed for logger or for a handler.

+

A filter which can be installed for the logger part of + Logger, or for a handler.

@@ -213,9 +242,9 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro ?LOG_DEBUG(FunOrFormat,Args[,Metadata]) -

All macros expand to a call to logger, where Level is - taken from the macro name, and location data is added. See the - description of +

All macros expand to a call to Logger, where Level is + taken from the macro name, and location data is added to the + metadata. See the description of the metadata() type for more information about the location data.

@@ -335,23 +364,26 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro - Lookup the current configuration for logger. + Look up the current configuration for the logger part + of Logger. -

Lookup the current configuration for logger.

+

Look up the current configuration for the logger part of + Logger.

- Lookup the current configuration for the given handler. + Look up the current configuration for the given + handler. -

Lookup the current configuration for the given handler.

+

Look up the current configuration for the given handler.

- Get all logger configurations + Get all Logger configurations

Same as logger:i(term)

@@ -361,28 +393,28 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro - Get all logger configurations + Get all Logger configurations -

Display or return all current logger configuration.

+

Display or return all current Logger configurations.

Action = string -

Return the pretty printed current logger configuration +

Return the pretty printed current Logger configuration as iodata.

Action = term -

Return the current logger configuration as a term. The - format of this term may change inbetween releases. For a +

Return the current Logger configuration as a term. The + format of this term may change between releases. For a stable format use logger:get_handler_config/1 and - logger:get_logger_config/0. - The same as calling logger:i().

+ logger:get_logger_config/0.

+

The same as calling logger:i().

Action = print -

Pretty print all the current logger configuration to +

Pretty print all the current Logger configuration to standard out. Example:

logger:i(print). Current logger configuration: @@ -423,9 +455,9 @@ Current logger configuration: - Add a filter to the logger. + Add a filter to the logger part of Logger. -

Add a filter to the logger.

+

Add a filter to the logger part of Logger.

The filter fun is called with the log event as the first parameter, and the specified filter_args() as the second parameter.

@@ -436,8 +468,8 @@ Current logger configuration:

The filter passed. The next logger filter, if any, is applied. If no more logger filters exist, the - log event is forwarded to the handler part of the - logger, where handler filters are applied.

+ log event is forwarded to the handler part of Logger, + where handler filters are applied.

stop @@ -449,9 +481,9 @@ Current logger configuration:

The filter has no knowledge of the log event. The next logger filter, if any, is applied. If no more logger filters exist, the value of the filter_default - configuration parameter for the logger specifies if the - log event shall be discarded or forwarded to the handler - part.

+ configuration parameter for the logger part specifies if + the log event shall be discarded or forwarded to the + handler part.

See section @@ -505,10 +537,10 @@ Current logger configuration: - Remove a filter from the logger. + Remove a filter from the logger part of Logger.

Remove the filter identified - by FilterId from the logger.

+ by FilterId from the logger part of Logger.

@@ -548,21 +580,21 @@ Current logger configuration:

Set the log level for the specified Module.

The log level for a module overrides the global log level - of the logger for log event originating from the module in + of Logger for log events originating from the module in question. Notice, however, that it does not override the level configuration for any handler.

-

For example: Assume that the global log level for the - logger is info, and there is one handler, h1, - with level info and one handler, h2, with +

For example: Assume that the global log level for Logger + is info, and there is one handler, h1, with + level info and one handler, h2, with level debug.

With this configuration, no debug messages will be logged, since they are all stopped by the global log level.

-

If the level for mymodule is set now set +

If the level for mymodule is now set to debug, then debug events from this module will be logged by the handler h2, but not by handler h1.

Debug events from other modules are still not logged.

-

To change the global log level for the logger, use +

To change the global log level for Logger, use logger:set_logger_config(level,Level).

To change the log level for a handler, use @@ -572,9 +604,10 @@ Current logger configuration:

The originating module for a log event is only detected if mfa=>{Module,Function,Arity} exists in the metadata. When log macros are used, this association is - automatically added to all log events. If the logger API + automatically added to all log events. If an API function is called directly, without using a macro, the logging - client must explicitly add this information.

+ client must explicitly add this information if module + levels shall have any effect.

@@ -590,10 +623,11 @@ Current logger configuration: - Setup logger handlers from the applications configuration parameters. + Set up log handlers from the application's + configuration parameters.

Reads the application configuration parameter logger and - calls logger:add_handlers/1 with it contents.

+ calls logger:add_handlers/1 with its contents.

@@ -602,11 +636,12 @@ Current logger configuration: Setup logger handlers. -

This function should be used by custom logger handlers to make +

This function should be used by custom Logger handlers to make configuration consistent no matter which handler the system uses. - Normal usage to to add a call to logger:add_handlers/1 - just after the processes that the handler needs are started - and pass the applications logger config as an argument. Eg.

+ Normal usage is to add a call to logger:add_handlers/1 + just after the processes that the handler needs are started, + and pass the application's logger configuration as the argument. + For example:

-behaviour(application). start(_, []) -> @@ -616,19 +651,20 @@ start(_, []) -> {ok, Pid, []}; Error -> Error end. -

This will read the logger configuration parameter from - the handler application and start the configured handlers. The contents - of the configuration use the same rules as the +

This reads the logger configuration parameter from + the my_all application and starts the configured + handlers. The contents of the configuration use the same + rules as the logger handler configuration.

-

If the handler is meant to replace the default handler the kernels - default handlers have to be disabled before the new handler is added. - A sys.config file that disables the kernel handler and adds - a custom handler could looks like this:

+

If the handler is meant to replace the default handler, the Kernel's + default handler have to be disabled before the new handler is added. + A sys.config file that disables the Kernel handler and adds + a custom handler could look like this:

[{kernel, [{logger, - %% Disable the default kernel handler + %% Disable the default Kernel handler [{handler,default,undefined}]}]}, {my_app, [{logger, @@ -640,10 +676,10 @@ start(_, []) -> - Set configuration data for the logger. + Set configuration data for the logger part of Logger. -

Set configuration data for the logger. This overwrites the - current logger configuration.

+

Set configuration data for the logger part of Logger. This + overwrites the current logger configuration.

To modify the existing configuration, use update_logger_config/1, or, if a more @@ -658,21 +694,25 @@ start(_, []) -> - Add or update configuration data for the logger. + Add or update configuration data for the logger part + of Logger. -

Add or update configuration data for the logger. If the - given Key already exists, its associated - value will be changed to Value. If it - does not exist, it will be added.

+

Add or update configuration data for the logger part of + Logger. If the given Key already exists, + its associated value will be changed + to Value. If it does not exist, it will + be added.

- Update configuration data for the logger. + Update configuration data for the logger part of + Logger. -

Update configuration data for the logger. This function - behaves as if it was implemented as follows:

+

Update configuration data for the logger part of + Logger. This function behaves as if it was implemented as + follows:

{ok,Old} = logger:get_logger_config(), logger:set_logger_config(maps:merge(Old,Config)). @@ -697,7 +737,7 @@ logger:set_logger_config(maps:merge(Old,Config)). , then do the merge before writing the new configuration back with this function.

If a key is removed compared to the current configuration, - and the key is know by Logger, the default value is used. If + and the key is known by Logger, the default value is used. If it is a custom key, then it is up to the handler implementation if the value is removed or a default value is inserted.

diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml index 4232429589..21b460e72a 100644 --- a/lib/kernel/doc/src/logger_chapter.xml +++ b/lib/kernel/doc/src/logger_chapter.xml @@ -36,14 +36,14 @@ this API can be used as is, or it can be customized to suite specific needs.

It consists of two parts - the logger part and the - handler part. The logger will forward log events to one - or more handler(s).

+ handler part. The logger part forwards log events to + one or more handler(s).

Conceptual overview -

Filters can be added to the logger and to each +

Filters can be added to the logger part and to each handler. The filters decide if an event is to be forwarded or not, and they can also modify all parts of the log event.

@@ -121,10 +121,10 @@ log(Log, Config) -> ok -

A handler is called by the logger backend after filtering on - logger level and on handler level for the handler which is - about to be called. The function call is done on the client - process, and it is up to the handler implementation if other +

The handler callback is called after filtering on logger + level and on handler level for the handler in + question. The function call is done on the client process, + and it is up to the handler implementation if other processes are to be involved or not.

Multiple instances of the same handler can be @@ -134,7 +134,7 @@ Filter -

Filters can be set on the logger or on a handler. Logger +

Filters can be set on the logger part, or on a handler. Logger filters are applied first, and if passed, the handler filters for each handler are applied. The handler callback is only called if all handler filters for the handler in question also @@ -145,7 +145,7 @@ {fun((Log,Extra) -> Log | stop | ignore), Extra}

The configuration parameter filter_default - specifies the behavior if all filters return ignore. + specifies the behaviour if all filters return ignore. filter_default is by default set to log.

The Extra parameter may contain any data that the @@ -250,52 +250,58 @@

Logger can be configured either when the system starts through configuration parameters, - or at run-time by using the logger + or at run-time by using the logger(3) API. The recommended approach is to do the initial configuration in the sys.config file and then use the API when some configuration - has to be changed at run-time, such as the logging level.

+ has to be changed at run-time, such as the log level.

- Application configuration parameters + Kernel Configuration Parameters

Logger is best configured by using the configuration parameters - of kernel. There are three possible configuration parameters: + of Kernel. There are four possible configuration parameters: logger, logger_level, logger_sasl_compatible and logger_log_progress. - logger_level, logger_sasl_compatible and logger_log_progress are described in the + logger_level, logger_sasl_compatible and logger_log_progress are described in the Kernel Configuration, while logger is described below.

-
+ - logger -

The logger application configuration parameter is used to configure - three different logger aspects; handlers, logger filters and module levels. +

logger

+

The application configuration parameter logger is used to configure + three different Logger aspects; handlers, logger filters and module levels. The configuration is a list containing tagged tuples that look like this:

DisableHandler = {handler,default,undefined} - Disable the default handler. This will allow another application + +

Disable the default handler. This allows another application to add its own default handler. See - logger:add_handlers/1 for more details. + logger:add_handlers/1 for more details.

+

Only one entry of this option is allowed.

AddHandler = {handler,HandlerId,Module,HandlerConfig} - Add a handler as if - logger:add_handler(HandlerId,Module,HandlerConfig) had been - called. - Filters = {filters, FilterDefault, [Filter]}
+ +

Add a handler as if + logger:add_handler(HandlerId,Module,HandlerConfig) is + called.

+

It is allowed to have multiple entries of this option.

+ Filters = {filters, default, [Filter]}
FilterDefault = log | stop
Filter = {FilterId, {FilterFun, FilterConfig}}
- Add the specified - logger filters. Only one entry is allowed of this option. - ModuleLevel - {module_level, Level, [Module]}, - this option configures the - module log level to be used. It is possible to have multiple - module_level entries. + +

Add the specified + logger filters.

+

Only one entry of this option is allowed.

+ ModuleLevel = {module_level, Level, [Module]} + +

This option configures + module log level.

+

It is allowed to have multiple entries of this option.

Examples:

-

Output logs into a the file "logs/erlang.log"

+

Output logs into the file "logs/erlang.log"

[{kernel, [{logger, @@ -338,7 +344,6 @@
-
@@ -441,36 +446,30 @@ error_logger in the following ways:

- Legacy event handlers - -

To use event handlers written for error_logger, just - add your event handler with

- -error_logger:add_report_handler/1,2. - -

This will automatically start the error_logger - event manager, and add error_logger as a - handler to logger, with configuration

- -#{level=>info, - filter_default=>log, - filters=>[]}. - -

Note that this handler will ignore events that do not - originate from the old error_logger API, or from - within OTP. This means that if your code uses the logger API - for logging, then your log events will be discarded by this - handler.

-

Also note that error_logger is not overload - protected.

-
- Logger API + API for Logging

The old error_logger API still exists, but should only be used by legacy code. It will be removed in a later release.

+

Calls + to + error_logger:error_report/1,2, + + error_logger:error_msg/1,2, and + corresponding functions for warning and info messages, are + all forwarded to Logger as calls + to + logger:log(Level,Report,Metadata).

+

Level = error | warning | info and is taken + from the function name. Report contains the actual + log message, and Metadata contains additional + information which can be used for creating backwards + compatible events for legacy error_logger event + handlers, see + section Legacy + Event Handlers.

- Output format + Output Format

To get log events on the same format as produced by error_logger_tty_h and error_logger_file_h, @@ -478,13 +477,13 @@ error_logger:add_report_handler/1,2. configuration parameter legacy_header=>true. This is also the default.

- Default format of log events from OTP + Default Format of Log Events from OTP

By default, all log events originating from within OTP, except the former so called "SASL reports", look the same as before.

- SASL reports + SASL Reports

By SASL reports we mean supervisor reports, crash reports and progress reports.

@@ -494,32 +493,63 @@ error_logger:add_report_handler/1,2. named sasl_report_tty_h and sasl_report_file_h.

The destination of these log events were configured by - environment variables for the SASL application.

+ SASL + configuration parameters.

Due to the specific event handlers, the output format slightly differed from other log events.

As of OTP-21, the concept of SASL reports is removed, - meaning that the default behavior is as follows:

+ meaning that the default behaviour is as follows:

Supervisor reports, crash reports and progress reports are no longer connected to the SASL application. Supervisor reports and crash reports are logged by default. Progress reports are not logged by default, but can be - enabled with the kernel environment - variable logger_log_progress. + enabled with the Kernel configuration + parameter + logger_log_progress.
The output format is the same for all log events. -

If the old behavior is preferred, the kernel environment - variable logger_sasl_compatible can be set - to true. The old SASL environment variables can then - be used as before, and the SASL reports will only be printed - if the SASL application is running - through a second log - handler named sasl_h.

+

If the old behaviour is preferred, the Kernel configuation + parameter + logger_sasl_compatible can be set + to true. The + old SASL + configuration parameters can then be used as + before, and the SASL reports will only be printed if the + SASL application is running, through a second log handler + named sasl_h.

All SASL reports have a metadata field domain=>[beam,erlang,otp,sasl], which can be used, for example, by filters to stop or allow the events.

+

See the SASL User's + Guide for more information about the old SASL + error logging functionality.

+ + Legacy Event Handlers + +

To use event handlers written for error_logger, just + add your event handler with

+ +error_logger:add_report_handler/1,2. + +

This will automatically start the error_logger + event manager, and add error_logger as a + handler to logger, with configuration

+ +#{level=>info, + filter_default=>log, + filters=>[]}. + +

Notice that this handler will ignore events that do not + originate from the old error_logger API, or from + within OTP. This means that if your code uses the Logger API + for logging, then your log events will be discarded by this + handler.

+

Also notice that error_logger is not overload + protected.

@@ -535,14 +565,14 @@ error_logger:add_report_handler/1,2. converting the report to a format string and arguments. The handler might also do a custom conversion if the default format is not desired.

-

logger does, to a certain extent, check its input data +

Logger does, to a certain extent, check its input data before forwarding a log event to the handlers, but it does not evaluate conversion funs or check the validity of format strings and arguments. This means that any filter or handler must be careful when formatting the data of a log event, making sure that it does not crash due to bad input data or faulty callbacks.

-

If a filter or handler still crashes, logger will remove the +

If a filter or handler still crashes, Logger will remove the filter or handler in question from the configuration, and then print a short error message on the console. A debug event containing the crash reason and other details is also issued, @@ -552,13 +582,13 @@ error_logger:add_report_handler/1,2.

Example: add a handler to log debug events to file -

When starting an erlang node, the default behavior is that all +

When starting an erlang node, the default behaviour is that all log events with level info and above are logged to the console. In order to also log debug events, you can either change the global log level to debug or add a separate handler to take care of this. In this example we will add a new handler which prints the debug events to a separate file.

-

First, we add an instance of logger_std_h with +

First, we add an instance of logger_std_h with type {file,File}, and we set the handler's level to debug:

@@ -575,9 +605,9 @@ ok
#Fun<erl_eval.12.98642416> 4> logger:add_handler_filter(debug_handler,allow_debug,{Fun,[]}). ok -

And finally, we need to make sure that the logger itself allows +

And finally, we need to make sure that Logger itself allows debug events. This can either be done by setting the global - logger level:

+ log level:

 5> logger:set_logger_config(level,debug).
 ok
@@ -599,21 +629,22 @@ adding_handler(logger:handler_id(),logger:config()) -> {ok,logger:config()} | {e removing_handler(logger:handler_id(),logger:config()) -> ok changing_config(logger:handler_id(),logger:config(),logger:config()) -> {ok,logger:config()} | {error,term()}
-

When logger:add_handler(Id,Module,Config) is called, logger - will first call Module:adding_handler(Id,Config), and if it - returns {ok,NewConfig} the NewConfig is written to the +

When logger:add_handler(Id,Module,Config) is called, Logger + will first call Module:adding_handler(Id,Config), and if it + returns {ok,NewConfig}, NewConfig is written to the configuration database. After this, the handler may receive log - events as calls to Module:log/2.

+ events as calls to Module:log/2.

A handler can be removed by calling - logger:remove_handler(Id). logger will call - Module:removing_handler(Id,Config), and then remove the handler's - configuration from the configuration database.

-

When logger:set_handler_config is called, logger calls - Module:changing_config(Id,OldConfig,NewConfig). If this function - returns ok, the NewConfig is written to the configuration - database.

- -

A simple handler which prints to the console could be + logger:remove_handler(Id). Logger will call + Module:removing_handler(Id,Config), and then remove the + handler's configuration from the configuration database.

+

When logger:set_handler_config/2,3 + or logger:update_handler_config/2 are called, Logger + calls Module:changing_config(Id,OldConfig,NewConfig). If + this function returns {ok,NewConfig}, NewConfig is + written to the configuration database.

+ +

A simple handler that prints to the console could be implemented as follows:

-module(myhandler). @@ -720,7 +751,7 @@ do_log(Fd,Log,#{formatter:={FModule,FConfig}}) -> and as long as the length of the message queue is lower, all log requests are handled asynchronously. This simply means that the process sending the log request (by calling a log function in the - logger API) does not wait for a response from the handler but + Logger API) does not wait for a response from the handler but continues executing immediately after the request (i.e. it will not be affected by the time it takes the handler to print to the log device). If the message queue grows larger than this value, however, @@ -876,7 +907,14 @@ logger:add_handler(my_disk_log_h, logger_disk_log_h,
See Also -

error_logger(3), - SASL(6)

+

+ disk_log(3), + error_logger(3), + logger(3), + logger_disk_log_h(3), + logger_filters(3), + logger_formatter(3), + logger_std_h(3), + sasl(6)

diff --git a/lib/kernel/doc/src/logger_disk_log_h.xml b/lib/kernel/doc/src/logger_disk_log_h.xml index 440ae28e5d..20b49b8ca0 100644 --- a/lib/kernel/doc/src/logger_disk_log_h.xml +++ b/lib/kernel/doc/src/logger_disk_log_h.xml @@ -33,21 +33,21 @@ logger_disk_log_h.xml logger_disk_log_h - A disk_log based handler for the Logger - application. + A disk_log based handler for the Logger. -

This is a handler for the Logger application that offers circular - (wrapped) logs by using the disk_log application. Multiple instances - of this handler can be added to logger, and each instance will print to +

This is a handler for Logger that offers circular + (wrapped) logs by using disk_log. + Multiple instances + of this handler can be added to Logger, and each instance prints to its own disk_log file, created with the name and settings specified in the handler configuration.

The default standard handler, logger_std_h, can be - replaced by a disk_log handler at startup of the kernel application. + replaced by a disk_log handler at startup of the Kernel application. See an example of this below.

The handler has an overload protection mechanism that will keep the handler - process and the kernel application alive during a high load of log + process and the Kernel application alive during a high load of log requests. How this feature works, and how to modify the configuration, is described in the User's Guide @@ -121,7 +121,7 @@ logger:add_handler(my_disk_log_h, logger_disk_log_h, #{filesync_repeat_interval => 1000}}).

In order to use the disk_log handler instead of the default standard - handler when starting en Erlang node, change the Kernel default logger to + handler when starting an Erlang node, change the Kernel default logger to use disk_log. Example:

erl -kernel logger '[{handler,default,logger_disk_log_h, @@ -141,6 +141,12 @@ erl -kernel logger '[{handler,default,logger_disk_log_h, +
+ See Also +

logger(3)

+

logger_std_h(3)

+

disk_log(3)

+
diff --git a/lib/kernel/doc/src/logger_formatter.xml b/lib/kernel/doc/src/logger_formatter.xml index 370d61d338..ee43634cf9 100644 --- a/lib/kernel/doc/src/logger_formatter.xml +++ b/lib/kernel/doc/src/logger_formatter.xml @@ -39,7 +39,8 @@

Each log handler has a configured formatter specified as a module and a configuration term. The purpose of the formatter is to translate the log events to a final printable string - (unicode:chardata()) which can be written to the output + (unicode:chardata() + ) which can be written to the output device of the handler.

logger_formatter is the default formatter used by Logger.

@@ -47,7 +48,8 @@
Configuration -

The configuration term for logger_formatter is a map, +

The configuration term for logger_formatter is a + map, and the following keys can be set as configuration parameters:

@@ -55,7 +57,7 @@

A positive integer representing the value of the option with the same name to be used when calling - io_lib:format/3. + io_lib:format/3. This value limits the total number of characters printed for each log event. Notice that this is a soft limit. For a hard truncation limit, see option max_size.

@@ -99,7 +101,7 @@ added by the template parameter are not replaced.

Default is true.

- legacy_header = boolen() + legacy_header = boolean()

If set to true a header field is added to logger_formatter's part of Metadata. The value of @@ -181,8 +183,8 @@ to "+02:00".

The default value is an empty string, meaning that timestamps are displayed in local time. However, for - backwards compatibility, if the SASL environment - variable + backwards compatibility, if the SASL configuration + parameter utc_log=true, the default is changed to "Z", meaning that timestamps are displayed in UTC.

@@ -206,28 +208,42 @@ ?LOG_ERROR("name: ~p~nexit_reason: ~p",[my_name,"It crashed"])
- legacy_header=true + legacy_header=true, single_line=false

Default template: [{logger_formatter,header},"\n",msg,"\n"]

Example log entry:

-2018-05-16T11:55:50.448382+02:00 error: +=ERROR REPORT==== 17-May-2018::18:30:19.453447 === name: my_name exit_reason: "It crashed" -

Notice that all eight levels might occur in the heading, +

Notice that all eight levels can occur in the heading, not only ERROR, WARNING or INFO as the old error_logger produced. And microseconds are added at the end of the timestamp.

- single_line=true + legacy_header=true, single_line=true + +

Default template: [{logger_formatter,header},"\n",msg,"\n"]

+ +

Notice that the template is here the same as + for single_line=false, but the resulting log entry + differs in that there is only one line after the + heading:

+ +=ERROR REPORT==== 17-May-2018::18:31:06.952665 === +name: my_name, exit_reason: "It crashed" +
+ + legacy_header=false, single_line=true

Default template: [time," ",level,": ",msg,"\n"]

Example log entry:

- 2018-05-16T11:55:50.448382+02:00 error: name: my_name, exit_reason: "It crashed" + +2018-05-17T18:31:31.152864+02:00 error: name: my_name, exit_reason: "It crashed"
legacy_header=false, single_line=false @@ -236,7 +252,7 @@ exit_reason: "It crashed"

Example log entry:

-2018-05-16T11:55:50.448382+02:00 error: +2018-05-17T18:32:20.105422+02:00 error: name: my_name exit_reason: "It crashed" diff --git a/lib/kernel/doc/src/logger_std_h.xml b/lib/kernel/doc/src/logger_std_h.xml index bf23d874c8..a4f2848037 100644 --- a/lib/kernel/doc/src/logger_std_h.xml +++ b/lib/kernel/doc/src/logger_std_h.xml @@ -33,17 +33,17 @@ logger_std_h.xml logger_std_h - Default handler for the Logger application. + Default handler for Logger. -

This is the default handler for the Logger - application. Multiple instances of this handler can be added to - logger, and each instance will print logs to standard_io, +

This is the default handler for Logger. + Multiple instances of this handler can be added to + Logger, and each instance will print logs to standard_io, standard_error or to file. The default instance that starts - with kernel is named default - which is the name to be used + with Kernel is named default - which is the name to be used for reconfiguration.

The handler has an overload protection mechanism that will keep the handler - process and the kernel application alive during a high load of log + process and the Kernel application alive during a high load of log requests. How this feature works, and how to modify the configuration, is described in the User's Guide @@ -104,7 +104,7 @@ logger:add_handler(my_standard_h, logger_std_h, filesync_repeat_interval => 1000}}).

In order to configure the default handler (that starts initially with - the kernel application) to log to file instead of standard_io, + the Kernel application) to log to file instead of standard_io, change the Kernel default logger to use a file. Example:

erl -kernel logger '[{handler,default,logger_std_h, @@ -127,6 +127,11 @@ erl -kernel logger '[{handler,default,logger_std_h, +
+ See Also +

logger(3)

+

logger_disk_log_h(3)

+
-- cgit v1.2.3 From cfbe1afe6ba1f1083c8aa41c7aeb422f253f5d23 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 18 May 2018 13:27:56 +0200 Subject: Add logger:update_formatter_config/2,3 --- lib/kernel/doc/src/logger.xml | 25 +++++++++++++++++++++++++ lib/kernel/doc/src/logger_chapter.xml | 6 +++--- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/logger.xml b/lib/kernel/doc/src/logger.xml index f7e740e90d..be733685cc 100644 --- a/lib/kernel/doc/src/logger.xml +++ b/lib/kernel/doc/src/logger.xml @@ -773,6 +773,31 @@ logger:set_handler_config(HandlerId,maps:merge(Old,Config)). + + + Update the formatter configuration for the specified handler. + +

Update the formatter configuration for the specified handler.

+

The new configuration is merged with the existing formatter + configuration.

+

To overwrite the existing configuration without any merge, + use + set_handler_config(HandlerId,formatter, + {FormatterModule,FormatterConfig}).

+
+
+ + + + Update the formatter configuration for the specified handler. + +

Update the formatter configuration for the specified handler.

+

This is equivalent + to
+ update_formatter_config(HandlerId,#{Key=>Value})

+
+
+ Compare the severity of two log levels. diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml index 21b460e72a..522d0ce29d 100644 --- a/lib/kernel/doc/src/logger_chapter.xml +++ b/lib/kernel/doc/src/logger_chapter.xml @@ -157,7 +157,7 @@

A formatter is defined as a module exporting the following function:

- format(Log,Extra) -> unicode:chardata() + format(Log,FConfig) -> unicode:chardata()

The formatter callback is called by each handler, and the returned string can be printed to the handler's destination @@ -413,12 +413,12 @@ return ignore.

Default is log.

- formatter = {Module::module(),Extra::term()} + formatter = {FModule::module(),FConfig::map()}

See Formatter for more information.

The default module is - logger_formatter, and Extra is + logger_formatter, and FConfig is it's configuration map.

HandlerConfig, term() = term() -- cgit v1.2.3 From 6342a95bdaa8681bf24f2dc8fba261d21b75c9e4 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 18 May 2018 14:26:24 +0200 Subject: Rename reset_module_level to unset_module_level --- lib/kernel/doc/src/logger.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/logger.xml b/lib/kernel/doc/src/logger.xml index be733685cc..13d3e182d4 100644 --- a/lib/kernel/doc/src/logger.xml +++ b/lib/kernel/doc/src/logger.xml @@ -613,7 +613,7 @@ Current logger configuration:
- + Remove a module specific log setting.

Remove a module specific log setting. After this, the -- cgit v1.2.3 From e484181ecc5c3e2928d10632138837eba3c3229e Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Sun, 20 May 2018 09:21:10 +0200 Subject: Update Logger documentation --- lib/kernel/doc/src/logger.xml | 140 +++++---- lib/kernel/doc/src/logger_arch.png | Bin 31459 -> 32377 bytes lib/kernel/doc/src/logger_chapter.xml | 535 ++++++++++++++++++++-------------- 3 files changed, 413 insertions(+), 262 deletions(-) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/logger.xml b/lib/kernel/doc/src/logger.xml index 13d3e182d4..e2f3dd6e83 100644 --- a/lib/kernel/doc/src/logger.xml +++ b/lib/kernel/doc/src/logger.xml @@ -36,33 +36,6 @@ API module for logging in Erlang/OTP. - - - - -

This module is the main API for logging in Erlang/OTP. It contains functions that allow applications to use a single log @@ -217,6 +190,15 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro erlang:system_time(microsecond).

+ + + +

Configuration data for the + formatter. See + logger_formatter(3) + for an example of a formatter implementation.

+
+
@@ -486,8 +468,8 @@ Current logger configuration: handler part.

-

See section - Filter in the User's Guide for more information +

See section + Filters in the User's Guide for more information about filters.

Some built-in filters exist. These are defined in logger_filters.

@@ -528,7 +510,7 @@ Current logger configuration:

See - section Filter + section Filters in the User's Guide for more information about filters.

Some built-in filters exist. These are defined in logger_filters.

@@ -891,14 +873,15 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
- Callback Functions + + Handler Callback Functions

The following functions are to be exported from a handler callback module.

- Module:adding_handler(HandlerId,Config1) -> {ok,Config2} | {error,Reason} + HModule:adding_handler(HandlerId,Config1) -> {ok,Config2} | {error,Reason} An instance of this handler is about to be added. HandlerId = @@ -911,7 +894,7 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).

This callback function is optional.

The function is called when an new handler is about to be added, and the purpose is to verify the configuration and - initiate all resourced needed by the handler.

+ initiate all resources needed by the handler.

If everything succeeds, the callback function can add possible default values or internal state values to the configuration, and return the adjusted map @@ -922,24 +905,7 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)). - Module:removing_handler(HandlerId,Config) -> ok - The given handler is about to be removed. - - HandlerId = - handler_id() - Config = - config() - - -

This callback function is optional.

-

The function is called when a handler is about to be - removed, and the purpose is to release all resources used by - the handler. The return value is ignored by Logger.

- -
- - - Module:changing_config(HandlerId,Config1,Config2) -> {ok,Config3} | {error,Reason} + HModule:changing_config(HandlerId,Config1,Config2) -> {ok,Config3} | {error,Reason} The configuration for this handler is about to change. HandlerId = @@ -961,6 +927,78 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)). return {error,Reason}.

+ + + HModule:log(Log,Config) -> void() + Log the given log event. + + Log = + log() + Config = + config() + + +

This callback function is mandatory.

+

The function is called when all global filters and all + handler filters for the handler in question have passed for + the given log event.

+

The handler must log the event.

+

The return value from this function is ignored by + Logger.

+
+
+ + + HModule:removing_handler(HandlerId,Config) -> ok + The given handler is about to be removed. + + HandlerId = + handler_id() + Config = + config() + + +

This callback function is optional.

+

The function is called when a handler is about to be + removed, and the purpose is to release all resources used by + the handler. The return value is ignored by Logger.

+
+
+ +
+ +
+ + Formatter Callback Functions +

The following functions are to be exported from a formatter + callback module.

+
+ + + + FModule:format(Log,FConfig) -> FormattedLogEntry + Format the given log event. + + Log = + log() + FConfig = + formatter_config() + FormattedLogEntry = + unicode:chardata() + + +

This callback function is mandatory.

+

The function can be called by a log handler to convert a + log event term to a printable string. The returned value + can, for example, be printed as a log entry to the console + or a file using + io:put_chars/1,2.

+

See + logger_formatter(3) + for an example implementation. logger_formatter is the + default formatter used by Logger.

+
+
diff --git a/lib/kernel/doc/src/logger_arch.png b/lib/kernel/doc/src/logger_arch.png index 727609a6ef..901122193a 100644 Binary files a/lib/kernel/doc/src/logger_arch.png and b/lib/kernel/doc/src/logger_arch.png differ diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml index 522d0ce29d..fd86e9e366 100644 --- a/lib/kernel/doc/src/logger_chapter.xml +++ b/lib/kernel/doc/src/logger_chapter.xml @@ -30,30 +30,44 @@ logger_chapter.xml +

As of OTP-21, Erlang/OTP provides a standard API for logging + through Logger, which is part of the Kernel + application. Logger consists of the API for issuing log events, + and a customizable backend where log handlers, filters and + formatters can be plugged in.

+

By default, the Kernel application installs one log handler at + system start. This handler is named default. It receives + and processes standard log events produced by the Erlang runtime + system, standard behaviours and different Erlang/OTP + applications. The log events are by default written to the + terminal.

+

You can also configure the system so that the default handler + prints log events to a single file, or to a set of wrap logs + via disk_log.

+

By confiugration, you can aslo modify or disable the default + handler, replace it by a custom handler, and install additional + handlers.

+
Overview -

Erlang/OTP provides a standard API for logging. The backend of - this API can be used as is, or it can be customized to suite - specific needs.

-

It consists of two parts - the logger part and the - handler part. The logger part forwards log events to - one or more handler(s).

+

A log event consists of a log level, the + message to be logged, and metadata.

+

The Logger backend forwards log events from the API, first + through a set of global filters, then through a set + of handler filters for each log handler.

+

Each filter set consists of a log level check, + followed by zero or more filter functions.

+

The following figure show a conseptual overview of Logger. The + figure shows two log handlers, but any number of handlers can be + installed.

- Conceptual overview + Conceptual Overview -

Filters can be added to the logger part and to each - handler. The filters decide if an event is to be forwarded or - not, and they can also modify all parts of the log event.

- -

A formatter can be set for each handler. The formatter - does the final formatting of the log event, including the log - message itself, and possibly a timestamp, header and other - metadata.

- -

In accordance with the Syslog protocol, RFC-5424, eight - severity levels can be specified:

+ +

In accordance with the Syslog protocol, RFC-5424, eight log + levels can be specified:

@@ -101,148 +115,216 @@ 7 debug-level messages - Severity levels + Log Levels
-

A log event is allowed by Logger if the integer value of - its Level is less than or equal to the currently - configured log level. The log level can be configured globally, - or to allow more verbose logging from a specific part of the - system, per module.

- -
- Customizable parts - - - Handler - -

A handler is defined as a module exporting the following - function:

- - log(Log, Config) -> ok - -

The handler callback is called after filtering on logger - level and on handler level for the handler in - question. The function call is done on the client process, - and it is up to the handler implementation if other - processes are to be involved or not.

- -

Multiple instances of the same handler can be - added. Configuration is per instance.

- -
- - Filter - -

Filters can be set on the logger part, or on a handler. Logger - filters are applied first, and if passed, the handler filters - for each handler are applied. The handler callback is only - called if all handler filters for the handler in question also - pass.

- -

A filter is specified as:

- - {fun((Log,Extra) -> Log | stop | ignore), Extra} - -

The configuration parameter filter_default - specifies the behaviour if all filters return ignore. - filter_default is by default set to log.

- -

The Extra parameter may contain any data that the - filter needs.

-
- - Formatter - -

A formatter is defined as a module exporting the following - function:

- - format(Log,FConfig) -> unicode:chardata() - -

The formatter callback is called by each handler, and the - returned string can be printed to the handler's destination - (stdout, file, ...).

-
- -
-
- -
- Built-in handlers - - - logger_std_h - -

This is the default handler used by OTP. Multiple instances - can be started, and each instance will write log events to a - given destination, console or file. Filters can be used for - selecting which event to send to which handler instance.

-
- - logger_disk_log_h - -

This handler behaves much like logger_std_h, except it uses - disk_log as its - destination.

-
- - error_logger - -

This handler is to be used for backwards compatibility - only. It is not started by default, but will be automatically - started the first time an event handler is added - with - error_logger:add_report_handler/1,2.

- -

No built-in event handlers exist.

-
-
-
- -
- Built-in filters - - - logger_filters:domain/2 - -

This filter provides a way of filtering log events based on a - domain field Metadata. See - - logger_filters:domain/2

-
+

A log event passes the level check if the integer value of its + log level is less than or equal to the currently configured log + level, that is, if the event is equally or more severe than the + configured level.

+

The global log level can be overridden by a log level + configured per module. This is to, for instance, allow more + verbose logging from a specific part of the system.

+

Filter functions can be used for more sophisticated filtering + than the log level check provides. A filter function can stop or + pass a log event, based on any of the event's contents. It can + also modify all parts of the log event. See see + section Filters for more + details.

+

If a log event passes through all global filters and all + handler filters for a specific handler, Logger forwards the event + to the handler callback. The handler formats and prints the + event to its destination. See + section Handlers for + more details.

+

Everything upto and including the call to the handler callbacks + is executed on the client process, that is, the process where + the log event was issued. It is up to the handler implementation + if other processes are to be involved or not.

+

The handlers are called in sequence, and the order is not + defined.

+
+
+ + Filters +

Filters can be global, or attached to a specific + handler. Logger calls the global filters first, and if they all + pass, it calls the handler filters for each handler. Logger + calls the handler callback only if all filters attached to the + handler in question also pass.

+

A filter is defined as:

+
{FilterFun, Extra}
+

where FilterFun is a function of arity 2, + and Extra is any term. When applying the filter, Logger + calls the function with the log event as the first argument, + and the value of Extra as the second + argument. See + logger:filter() for type definitions.

+

The filter function can return stop, ignore or + the (possibly modified) log event.

+

If stop is returned, the log event is immediately + discarded. If the filter is global, no handler filters or + callbacks are called. If it is a handler filter, the + corresponding handler callback is not called, but the log event + is forwarded to the filters attached to the next handler, if + any.

+

If the log event is returned, the next filter function is + called with the returned value as the first argument. That is, + if a filter function modifies the log event, the next filter + function receivea the modified event. The value returned from + the last filter funcion is the value that the handler callback + receives.

+

If the filter function returns ignore, it means that it + did not recognize the log event, and thus leaves to other + filters to decide the event's destiny.

+

The configuration + option filter_default + specifies the behaviour if all filter functions + return ignore. filter_default is by default set + to log, meaning that if all filters ignore a log event, + Logger forwards the event to the handler + callback. If filter_default is set to stop, + Logger discards such events.

+ +

Filters are applied in the reverse order of installation, + meaning that the last added filter is applied first.

+ +

Global filters are added + with + logger:add_logger_filter/2 + and removed + with + logger:remove_logger_filter/1. They can also + be added at system start via Kernel configuration + parameter logger.

+

Handler filters are added with + with + logger:add_handler_filter/3 + and removed + with + logger:remove_handler_filter/2. They can also + be specified directly in the configuration when adding a handler + with + logger:add_handler/3 + or via Kernel configuration + parameter logger.

+ +

To see which filters are currently installed in the system, + use logger:i/0, + or + logger:get_logger_config/0 + and + logger:get_handler_config/1. Filters are + applied in the order they are listed.

+ +

For convenience, the following built-in filters exist:

+ + + +

+ logger_filters:domain/2 provides a way of + filtering log events based on a + domain field Metadata.

+
+ +

+ logger_filters:level/2 provides a way of + filtering log events based on the log level.

+
+ +

+ logger_filters:progress/2 stops or allows + progress reports from supervisor + and application_controller.

+
+ +

+ logger_filters:remote_gl/2 stops or allows + log events originating from a process that has its group + leader on a remote node.

+
+
+
- logger_filters:level/2 - -

This filter provides a way of filtering log events based - on the log level. See - logger_filters:level/2

-
+
+ + Handlers +

A handler is defined as a module exporting at least the + following function:

+ +
log(Log, Config)
+ +

This function is called when a log event has passed through all + global filters, and all handler filters attached to the handler + in question. The function call is executed on the client + process, and it is up to the handler implementation if other + processes are to be involved or not.

+ +

Logger allows adding multiple instances of a handler + callback. That is, the callback module might be implemented in + such a way that, by using different handler identities, the same + callback module can be used for multiple handler + instances. Handler configuration is per instance.

+ +

In addition to the mandatory callback function log/2, a + handler module can export the optional callback + functions adding_handler/2, changing_config/3 + and removing_handler/1. See + section Handler + Callback Functions in the logger(3) manual for more + information about these function.

+ +

The following built-in handlers exist:

- logger_filters:progress/2 - -

This filter matches all progress reports - from supervisor and application_controller. - See - logger_filters:progress/2

-
+ + logger_std_h + +

This is the default handler used by OTP. Multiple instances + can be started, and each instance will write log events to a + given destination, console or file. Filters can be used for + selecting which event to send to which handler instance.

+
- logger_filters:remote_gl/2 - -

This filter matches all events originating from a process - that has its group leader on a remote node. - See - logger_filters:remote_gl/2

-
-
-
+ logger_disk_log_h + +

This handler behaves much like logger_std_h, except it uses + disk_log as its + destination.

+
-
- Default formatter + error_logger + +

This handler is to be used for backwards compatibility + only. It is not started by default, but will be + automatically started the first time an error_logger + event handler is added + with + error_logger:add_report_handler/1,2.

+ +

The old error_logger event handlers in STDLIB and + SASL still exist, but they are not added by Erlang/OTP.

+
+ +
-

The default formatter is logger_formatter. - See - logger_formatter:format/2.

-
+
+ + Formatters +

A formatter can be used by the handler implementation to do the + final formatting of a log event, before printing to the + handler's destination. The handler callback gets the formatter + information in the handler configuration, which is passed as the + second argument to + HModule:log/2.

+

The formatter information consits of a formatter + module, FModule and its + configuration, FConfig. FModule must export the + following function, which can be called by the handler:

+
format(Log,FConfig)
+	-> FormattedLogEntry
+

See the + logger_formatter(3) manual for the full + description of the default formatter used by Logger.

@@ -347,101 +429,130 @@
- Logger configuration + Global Logger Configuration - level + level = + logger:level() -

Specifies the severity level to log.

+

Specifies the global log level to log.

+

See table Log + Levels in the Overview section for a listing + and description of possible log levels.

+

The initial value of this option is set by the Kernel + configuration + parameter + logger_level. It can be changed during + runtime + with + logger:set_logger_config(level,NewLevel).

- filters + filters = [{ + logger:filter_id(), + + logger:filter()}] -

Logger filters are added or removed with +

Global filters are added and removed with logger:add_logger_filter/2 and logger:remove_logger_filter/1, respectively.

-

See Filter for more - information.

-

By default, no filters exist.

+

See section Filters + for more information.

+

Default is [], that is, no filters exist.

- filter_default = log | stop + filter_default = log | stop

Specifies what to do with an event if all filters return ignore.

+

See section Filters + for more information about how this option is used.

Default is log.

- handlers - -

Handlers are added or removed with - - logger:add_handler/3 and - - logger:remove_handler/1, - respectively.

-

See Handler for more - information.

-
- Handler configuration + Handler Configuration - level + level = + logger:level() -

Specifies the severity level to log.

+

Specifies the log level which the handler logs.

+

See table Log + Levels in the Overview section for a listing + and description of possible log levels.

+

The log level can be specified when adding the handler, + or changed during runtime with, for + instance, + logger:set_handler_config/3.

+

Default is info.

- filters + filters = [{ + logger:filter_id(), + + logger:filter()}]

Handler filters can be specified when adding the handler, - or added or removed later with + or added or removed during runtime with logger:add_handler_filter/3 and logger:remove_handler_filter/2, respectively.

-

See Filter for more +

See Filters for more information.

-

By default, no filters exist.

+

Default is [], that is, no filters exist.

- filter_default = log | stop + filter_default = log | stop

Specifies what to do with an event if all filters return ignore.

+

See section Filters + for more information about how this option is used.

Default is log.

- formatter = {FModule::module(),FConfig::map()} + formatter = {module(), + logger:formatter_config()} -

See Formatter for more +

The formatter which the handler can use for converting + the log event term to a printable string.

+

See Formatters for more information.

-

The default module is - logger_formatter, and FConfig is - it's configuration map.

+

Default + is {logger_formatter,DefaultFormatterConfig}, see + the + logger_formatter(3) + manual for information about this formatter and its + default configuration.

- HandlerConfig, term() = term() + HandlerConfig, atom() = term() - Any keys not listed above are considered to be handler specific - configuration. The configuration of the Kernel handlers can be found in - logger_std_h and - logger_disk_log_h. +

Any keys not listed above are considered to be handler + specific configuration. The configuration of the Kernel + handlers can be found in + the logger_std_h(3) + and + logger_disk_log_h(3) + manual pages.

-

Note that level and filters are obeyed by +

Notice that level and filters are obeyed by Logger itself before forwarding the log events to each - handler, while formatter is left to the handler - implementation. All Logger's built-in handlers will call the - given formatter before printing.

+ handler, while formatter and all handle specific + options are left to the handler implementation.

+

All Logger's built-in handlers will call the given formatter + before printing.

- Backwards compatibility with error_logger + Backwards Compatibility with error_logger

Logger provides backwards compatibility with the old error_logger in the following ways:

@@ -556,15 +667,17 @@ error_logger:add_report_handler/1,2.
- Error handling + Error Handling

Log data is expected to be either a format string and - arguments, a string (unicode:chardata), or a report (map or + arguments, a string + ( + unicode:chardata()), or a report (map or key-value list) which can be converted to a format string and - arguments by the handler. A default report callback should be - included in the log event's metadata, which can be used for - converting the report to a format string and arguments. The - handler might also do a custom conversion if the default format - is not desired.

+ arguments by the handler. If a report is given, a default report + callback can be included in the log event's metadata. The + handler can use this callback for converting the report to a + format string and arguments. The handler might also do a custom + conversion if the default format is not desired.

Logger does, to a certain extent, check its input data before forwarding a log event to the handlers, but it does not evaluate conversion funs or check the validity of format strings @@ -630,17 +743,17 @@ removing_handler(logger:handler_id(),logger:config()) -> ok changing_config(logger:handler_id(),logger:config(),logger:config()) -> {ok,logger:config()} | {error,term()}

When logger:add_handler(Id,Module,Config) is called, Logger - will first call Module:adding_handler(Id,Config), and if it + will first call HModule:adding_handler(Id,Config), and if it returns {ok,NewConfig}, NewConfig is written to the configuration database. After this, the handler may receive log - events as calls to Module:log/2.

+ events as calls to HModule:log/2.

A handler can be removed by calling logger:remove_handler(Id). Logger will call - Module:removing_handler(Id,Config), and then remove the + HModule:removing_handler(Id,Config), and then remove the handler's configuration from the configuration database.

When logger:set_handler_config/2,3 or logger:update_handler_config/2 are called, Logger - calls Module:changing_config(Id,OldConfig,NewConfig). If + calls HModule:changing_config(Id,OldConfig,NewConfig). If this function returns {ok,NewConfig}, NewConfig is written to the configuration database.

@@ -723,7 +836,7 @@ do_log(Fd,Log,#{formatter:={FModule,FConfig}}) ->
- Protecting the handler from overload + Protecting the Handler from Overload

In order for the built-in handlers to survive, and stay responsive, during periods of high load (i.e. when huge numbers of incoming log requests must be handled), a mechanism for overload protection @@ -734,7 +847,7 @@ do_log(Fd,Log,#{formatter:={FModule,FConfig}}) -> as follows:

- Message queue length + Message Queue Length

The handler process keeps track of the length of its message queue and reacts in different ways depending on the current status. The purpose is to keep the handler in, or (as quickly as possible), @@ -829,7 +942,7 @@ logger:add_handler(my_standard_h, logger_std_h,

- Controlling bursts of log requests + Controlling Bursts of Log Requests

A potential problem with large bursts of log requests, is that log files may get full or wrapped too quickly (in the latter case overwriting previously logged data that could be of great importance). For this reason, @@ -870,7 +983,7 @@ logger:add_handler(my_disk_log_h, logger_disk_log_h,

- Terminating a large handler + Terminating a Large Handler

A handler process may grow large even if it can manage peaks of high load without crashing. The overload protection mechanism includes user configurable levels for a maximum allowed message queue length and maximum allowed memory -- cgit v1.2.3 From d35c100a10239edc669b465a2176000ffcc1300f Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 21 May 2018 16:47:46 +0200 Subject: Change Compare parameter to logger_filters:domain/2 This configuration option has been removed. logger_formatter will read the utc_log configuration parameter and format the timestamp accordingly. --- lib/kernel/doc/src/logger.xml | 4 +- lib/kernel/doc/src/logger_chapter.xml | 2 +- lib/kernel/doc/src/logger_filters.xml | 145 +++++++++++++++++++++------------- 3 files changed, 95 insertions(+), 56 deletions(-) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/logger.xml b/lib/kernel/doc/src/logger.xml index e2f3dd6e83..6e50473fa8 100644 --- a/lib/kernel/doc/src/logger.xml +++ b/lib/kernel/doc/src/logger.xml @@ -421,10 +421,10 @@ Current logger configuration: Config: stop Id: domain Fun: fun logger_filters:domain/2 - Config: {log,prefix_of,[beam,erlang,otp,sasl]} + Config: {log,super,[beam,erlang,otp,sasl]} Id: no_domain Fun: fun logger_filters:domain/2 - Config: {log,no_domain,[]} + Config: {log,undefined,[]} Handler Config: logger_std_h: #{type => standard_io} Level set per module: diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml index fd86e9e366..34c65be47a 100644 --- a/lib/kernel/doc/src/logger_chapter.xml +++ b/lib/kernel/doc/src/logger_chapter.xml @@ -594,7 +594,7 @@ except the former so called "SASL reports", look the same as before.

- SASL Reports + SASL Reports

By SASL reports we mean supervisor reports, crash reports and progress reports.

diff --git a/lib/kernel/doc/src/logger_filters.xml b/lib/kernel/doc/src/logger_filters.xml index 1bbae8be21..f92181ea3f 100644 --- a/lib/kernel/doc/src/logger_filters.xml +++ b/lib/kernel/doc/src/logger_filters.xml @@ -52,61 +52,100 @@ - Filter log events based on the domain field in metadata. + Filter log events based on the domain field in + metadata. -

This filter provides a way of filtering log events based on a - domain field Metadata.

- -

The Extra parameter is specified when - adding the filter - via - logger:add_logger_filter/2 - or - logger:add_handler_filter/3.

- -

The filter compares the value of the domain field - in the log event's metadata (Domain) - to MatchDomain as follows:

- - - Compare = starts_with -

The filter matches if MatchDomain is a prefix - of Domain.

- Compare = prefix_of -

The filter matches if Domain is a prefix - of MatchDomain.

- Compare = equals -

The filter matches if Domain is equal - to MatchDomain.

- Compare = differs -

The filter matches if Domain differs - from MatchDomain, or if there is no domain field - in metadata.

- Compare = no_domain -

The filter matches if there is no domain field in - metadata. In this case MatchDomain shall - be [].

-
- -

If the filter matches and Action = - log, the log event is allowed. If the filter matches - and Action = stop, the log event is - stopped.

- -

If the filter does not match, it returns ignore, - meaning that other filters, or the value of the - configuration parameter filter_default, will decide - if the event is allowed or not.

- -

Log events that do not contain any domain field, will - only match when Compare = no_domain.

- -

Example: stop all events with - domain [beam,erlang,otp,sasl|_]

- - +

This filter provides a way of filtering log events based on a + domain field in Metadata. This field is + optional, and the purpose of using it is to group log events + from, for example, a specific functional area. This allows + filtering or other specialized treatment in a Logger + handler.

+ +

A domain field must be a list of atoms, creating smaller + and more specialized domains as the list grows longer. The + biggest domain is [], which comprices all + possible domains.

+ +

For example, consider the following domains:

+
+D1 = [beam,erlang,otp]
+D2 = [beam,erlang,otp,sasl]
+ +

D1 is the biggest of the two, and is said to be a + super-domain of D2. D2 is a + sub-domain D1. Both D1 and D2 are + sub-domains of []

+ +

The above domains are used for logs originating from + Erlang/OTP. D1 specifies that the log event comes from + Erlang/OTP in general, and D2 indicates that the log event + is a so + called SASL + report.

+ +

The Extra parameter to + the domain/2 function is specified when adding the + filter via + logger:add_logger_filter/2 + or + logger:add_handler_filter/3.

+ +

The filter compares the value of the domain field + in the log event's metadata (Domain) + to MatchDomain as follows:

+ + + Compare = sub + +

The filter matches if Domain is equal to or + a sub-domain of MatchDomain, that is, + if MatchDomain is a prefix of Domain.

+
+ Compare = super + +

The filter matches if Domain is equal to or a + super-domain of MatchDomain, that is, + if Domain is a prefix of MatchDomain.

+
+ Compare = equal + +

The filter matches if Domain is equal + to MatchDomain.

+
+ Compare = not_equal + +

The filter matches if Domain is not equal + to MatchDomain, or if there is no domain field in + metadata.

+
+ Compare = undefined +

The filter matches if there is no domain field in + metadata. In this case MatchDomain + must be set to [].

+
+
+ +

If the filter matches and Action = log, + the log event is allowed. If the filter matches + and Action = stop, the log event is + stopped.

+ +

If the filter does not match, it returns ignore, + meaning that other filters, or the value of the + configuration parameter filter_default, decide if the + event is allowed or not.

+ +

Log events that do not contain any domain field, match only + when Compare = undefined + or Compare = not_equal.

+ +

Example: stop all events with + domain [beam,erlang,otp,sasl|_]

+ + logger:set_handler_config(h1,filter_default,log). % this is the default -Filter = {fun logger_filters:domain/2,{stop,starts_with,[beam,erlang,otp,sasl]}}. +Filter = {fun logger_filters:domain/2,{stop,sub,[beam,erlang,otp,sasl]}}. logger:add_handler_filter(h1,no_sasl,Filter). ok
-- cgit v1.2.3 From ca1bf7a9d915a973203aa046bb9f921c11681ee0 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 21 May 2018 16:52:23 +0200 Subject: Change handler id for sasl handler from sasl_h to sasl --- lib/kernel/doc/src/kernel_app.xml | 2 +- lib/kernel/doc/src/logger_chapter.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/kernel_app.xml b/lib/kernel/doc/src/kernel_app.xml index 5bc423afb6..a9292e7660 100644 --- a/lib/kernel/doc/src/kernel_app.xml +++ b/lib/kernel/doc/src/kernel_app.xml @@ -192,7 +192,7 @@ will not log any progress-, crash-, or supervisor reports. If the SASL application is started, these log events will be sent to a second handler instance - named sasl_h, according to values of the SASL + named sasl, according to values of the SASL configuration parameter sasl_error_logger and sasl_errlog_type, see sasl(6) diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml index 34c65be47a..1195808160 100644 --- a/lib/kernel/doc/src/logger_chapter.xml +++ b/lib/kernel/doc/src/logger_chapter.xml @@ -630,7 +630,7 @@ configuration parameters can then be used as before, and the SASL reports will only be printed if the SASL application is running, through a second log handler - named sasl_h.

+ named sasl.

All SASL reports have a metadata field domain=>[beam,erlang,otp,sasl], which can be used, for example, by filters to stop or allow the -- cgit v1.2.3 From f38163aa64547e09f99e362edefeda713e06ddb7 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 21 May 2018 17:45:21 +0200 Subject: Remove HandlerId from handler callback functions and add it to Config --- lib/kernel/doc/src/logger.xml | 23 +++++++++++++---------- lib/kernel/doc/src/logger_chapter.xml | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 23 deletions(-) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/logger.xml b/lib/kernel/doc/src/logger.xml index 6e50473fa8..d6576db6f3 100644 --- a/lib/kernel/doc/src/logger.xml +++ b/lib/kernel/doc/src/logger.xml @@ -881,11 +881,9 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)). - HModule:adding_handler(HandlerId,Config1) -> {ok,Config2} | {error,Reason} + HModule:adding_handler(Config1) -> {ok,Config2} | {error,Reason} An instance of this handler is about to be added. - HandlerId = - handler_id() Config1 = Config2 = config() Reason = term() @@ -895,6 +893,8 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).

The function is called when an new handler is about to be added, and the purpose is to verify the configuration and initiate all resources needed by the handler.

+

The handler identity is associated with the id key + in Config1.

If everything succeeds, the callback function can add possible default values or internal state values to the configuration, and return the adjusted map @@ -905,11 +905,9 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)). - HModule:changing_config(HandlerId,Config1,Config2) -> {ok,Config3} | {error,Reason} + HModule:changing_config(Config1,Config2) -> {ok,Config3} | {error,Reason} The configuration for this handler is about to change. - HandlerId = - handler_id() Config1 = Config2 = Config3 = config() Reason = term() @@ -921,6 +919,8 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)). the new configuration.

Config1 is the existing configuration and Config2 is the new configuration.

+

The handler identity is associated with the id key + in Config1.

If everything succeeds, the callback function must return a possibly adjusted configuration in {ok,Config3}.

If the configuration is faulty, the callback function must @@ -942,6 +942,8 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).

The function is called when all global filters and all handler filters for the handler in question have passed for the given log event.

+

The handler identity is associated with the id key + in Config.

The handler must log the event.

The return value from this function is ignored by Logger.

@@ -949,11 +951,9 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
- HModule:removing_handler(HandlerId,Config) -> ok + HModule:removing_handler(Config) -> ok The given handler is about to be removed. - HandlerId = - handler_id() Config = config() @@ -961,7 +961,10 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).

This callback function is optional.

The function is called when a handler is about to be removed, and the purpose is to release all resources used by - the handler. The return value is ignored by Logger.

+ the handler.

+

The handler identity is associated with the id key + in Config.

+

The return value is ignored by Logger.

diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml index 1195808160..78c595d521 100644 --- a/lib/kernel/doc/src/logger_chapter.xml +++ b/lib/kernel/doc/src/logger_chapter.xml @@ -268,7 +268,7 @@

In addition to the mandatory callback function log/2, a handler module can export the optional callback - functions adding_handler/2, changing_config/3 + functions adding_handler/1, changing_config/2 and removing_handler/1. See section Handler Callback Functions in the logger(3) manual for more @@ -738,22 +738,22 @@ ok log(logger:log(),logger:config()) ->ok

It may also implement the following callbacks:

-adding_handler(logger:handler_id(),logger:config()) -> {ok,logger:config()} | {error,term()} -removing_handler(logger:handler_id(),logger:config()) -> ok -changing_config(logger:handler_id(),logger:config(),logger:config()) -> {ok,logger:config()} | {error,term()} +adding_handler(logger:config()) -> {ok,logger:config()} | {error,term()} +removing_handler(logger:config()) -> ok +changing_config(logger:config(),logger:config()) -> {ok,logger:config()} | {error,term()}

When logger:add_handler(Id,Module,Config) is called, Logger - will first call HModule:adding_handler(Id,Config), and if it + will first call HModule:adding_handler(Config), and if it returns {ok,NewConfig}, NewConfig is written to the configuration database. After this, the handler may receive log events as calls to HModule:log/2.

A handler can be removed by calling logger:remove_handler(Id). Logger will call - HModule:removing_handler(Id,Config), and then remove the + HModule:removing_handler(Config), and then remove the handler's configuration from the configuration database.

When logger:set_handler_config/2,3 or logger:update_handler_config/2 are called, Logger - calls HModule:changing_config(Id,OldConfig,NewConfig). If + calls HModule:changing_config(OldConfig,NewConfig). If this function returns {ok,NewConfig}, NewConfig is written to the configuration database.

@@ -771,14 +771,14 @@ log(Log,#{formatter:={FModule,FConfig}) -> this:

-module(myhandler). --export([adding_handler/2, removing_handler/2, log/2]). +-export([adding_handler/1, removing_handler/1, log/2]). -export([init/1, handle_call/3, handle_cast/2, terminate/2]). -adding_handler(Id,Config) -> +adding_handler(Config) -> {ok,Fd} = file:open(File,[append,{encoding,utf8}]), {ok,Config#{myhandler_fd=>Fd}}. -removing_handler(Id,#{myhandler_fd:=Fd}) -> +removing_handler(#{myhandler_fd:=Fd}) -> _ = file:close(Fd), ok. @@ -800,14 +800,14 @@ log(Log,#{myhandler_fd:=Fd,formatter:={FModule,FConfig}}) -> single process.

-module(myhandler). --export([adding_handler/2, removing_handler/2, log/2]). +-export([adding_handler/1, removing_handler/1, log/2]). -export([init/1, handle_call/3, handle_cast/2, terminate/2]). -adding_handler(Id,Config) -> +adding_handler(Config) -> {ok,Pid} = gen_server:start(?MODULE,Config), {ok,Config#{myhandler_pid=>Pid}}. -removing_handler(Id,#{myhandler_pid:=Pid}) -> +removing_handler(#{myhandler_pid:=Pid}) -> gen_server:stop(Pid). log(Log,#{myhandler_pid:=Pid} = Config) -> -- cgit v1.2.3 From 51c6464a011eacd78340b60e2641eaecc36933f6 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 21 May 2018 17:59:10 +0200 Subject: Change env var logger_log_progress to logger_progress_reports --- lib/kernel/doc/src/kernel_app.xml | 10 +++++----- lib/kernel/doc/src/logger_chapter.xml | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/kernel_app.xml b/lib/kernel/doc/src/kernel_app.xml index a9292e7660..0f7e95472b 100644 --- a/lib/kernel/doc/src/kernel_app.xml +++ b/lib/kernel/doc/src/kernel_app.xml @@ -204,17 +204,17 @@

This configuration option only effects the default and sasl handler. Any other handlers are uneffected.

- - logger_log_progress = boolean() + + logger_progress_reports = stop | log

If logger_sasl_compatible = false, - then logger_log_progress specifies if progress + then logger_progress_reports specifies if progress reports from supervisor and application_controller shall be logged by the default logger.

If logger_sasl_compatible = true, - then logger_log_progress is ignored.

-

The default value is false

+ then logger_progress_reports is ignored.

+

The default value is stop

This configuration option only effects the default and sasl handler. Any other handlers are uneffected.

diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml index 78c595d521..dff9ee2892 100644 --- a/lib/kernel/doc/src/logger_chapter.xml +++ b/lib/kernel/doc/src/logger_chapter.xml @@ -344,8 +344,8 @@ logger, logger_level, logger_sasl_compatible and - logger_log_progress. - logger_level, logger_sasl_compatible and logger_log_progress are described in the + logger_progress_reports. + logger_level, logger_sasl_compatible and logger_progress_reports are described in the Kernel Configuration, while logger is described below.

@@ -617,8 +617,8 @@ default. Progress reports are not logged by default, but can be enabled with the Kernel configuration - parameter - logger_log_progress. + parameter + logger_progress_reports. The output format is the same for all log events. -- cgit v1.2.3 From 72f1ce276401e0b8de9c0c527cbc324da0186939 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 23 May 2018 12:34:30 +0200 Subject: Change type name logger:log() to logger:log_event() --- lib/kernel/doc/src/logger.xml | 18 +++++++++--------- lib/kernel/doc/src/logger_chapter.xml | 26 +++++++++++++------------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/logger.xml b/lib/kernel/doc/src/logger.xml index d6576db6f3..bb356c5b86 100644 --- a/lib/kernel/doc/src/logger.xml +++ b/lib/kernel/doc/src/logger.xml @@ -87,7 +87,7 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro - +

@@ -446,7 +446,7 @@ Current logger configuration:

The return value of the fun specifies if a log event is to be discarded or forwarded to the handlers:

- log() + log_event()

The filter passed. The next logger filter, if any, is applied. If no more logger filters exist, the @@ -487,7 +487,7 @@ Current logger configuration:

The return value of the fun specifies if a log event is to be discarded or forwarded to the handler callback:

- log() + log_event()

The filter passed. The next handler filter, if any, is applied. If no more filters exist for this @@ -929,11 +929,11 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)). - HModule:log(Log,Config) -> void() + HModule:log(LogEvent,Config) -> void() Log the given log event. - Log = - log() + LogEvent = + log_event() Config = config() @@ -979,11 +979,11 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)). - FModule:format(Log,FConfig) -> FormattedLogEntry + FModule:format(LogEvent,FConfig) -> FormattedLogEntry Format the given log event. - Log = - log() + LogEvent = + log_event() FConfig = formatter_config() FormattedLogEntry = diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml index dff9ee2892..3b4cafb010 100644 --- a/lib/kernel/doc/src/logger_chapter.xml +++ b/lib/kernel/doc/src/logger_chapter.xml @@ -252,7 +252,7 @@

A handler is defined as a module exporting at least the following function:

-
log(Log, Config)
+
log(LogEvent, Config)

This function is called when a log event has passed through all global filters, and all handler filters attached to the handler @@ -320,7 +320,7 @@ module, FModule and its configuration, FConfig. FModule must export the following function, which can be called by the handler:

-
format(Log,FConfig)
+    
format(LogEvent,FConfig)
 	-> FormattedLogEntry

See the logger_formatter(3) manual for the full @@ -735,7 +735,7 @@ ok

Example: implement a handler

The only requirement that a handler MUST fulfill is to export the following function:

- log(logger:log(),logger:config()) ->ok + log(logger:log_event(),logger:config()) -> ok

It may also implement the following callbacks:

adding_handler(logger:config()) -> {ok,logger:config()} | {error,term()} @@ -763,8 +763,8 @@ changing_config(logger:config(),logger:config()) -> {ok,logger:config()} | {erro -module(myhandler). -export([log/2]). -log(Log,#{formatter:={FModule,FConfig}) -> - io:put_chars(FModule:format(Log,FConfig)). +log(LogEvent,#{formatter:={FModule,FConfig}) -> + io:put_chars(FModule:format(LogEvent,FConfig)).

A simple handler which prints to file could be implemented like @@ -782,8 +782,8 @@ removing_handler(#{myhandler_fd:=Fd}) -> _ = file:close(Fd), ok. -log(Log,#{myhandler_fd:=Fd,formatter:={FModule,FConfig}}) -> - io:put_chars(Fd,FModule:format(Log,FConfig)). +log(LogEvent,#{myhandler_fd:=Fd,formatter:={FModule,FConfig}}) -> + io:put_chars(Fd,FModule:format(LogEvent,FConfig)).

The above handlers do not have any overload @@ -810,8 +810,8 @@ adding_handler(Config) -> removing_handler(#{myhandler_pid:=Pid}) -> gen_server:stop(Pid). -log(Log,#{myhandler_pid:=Pid} = Config) -> - gen_server:cast(Pid,{log,Log,Config}). +log(LogEvent,#{myhandler_pid:=Pid} = Config) -> + gen_server:cast(Pid,{log,LogEvent,Config}). init(#{myhandler_file:=File}) -> {ok,Fd} = file:open(File,[append,{encoding,utf8}]), @@ -820,16 +820,16 @@ init(#{myhandler_file:=File}) -> handle_call(_,_,State) -> {reply,{error,bad_request},State}. -handle_cast({log,Log,Config},#{fd:=Fd} = State) -> - do_log(Fd,Log,Config), +handle_cast({log,LogEvent,Config},#{fd:=Fd} = State) -> + do_log(Fd,LogEvent,Config), {noreply,State}. terminate(Reason,#{fd:=Fd}) -> _ = file:close(Fd), ok. -do_log(Fd,Log,#{formatter:={FModule,FConfig}}) -> - String = FModule:format(Log,FConfig), +do_log(Fd,LogEvent,#{formatter:={FModule,FConfig}}) -> + String = FModule:format(LogEvent,FConfig), io:put_chars(Fd,String).

-- cgit v1.2.3 From 53539ee751da408029c9dfae80384fdec6c7a552 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Tue, 22 May 2018 13:22:55 +0200 Subject: Update documentation of logger and error_logger --- lib/kernel/doc/src/error_logger.xml | 233 ++++++++++------ lib/kernel/doc/src/kernel_app.xml | 8 +- lib/kernel/doc/src/logger.xml | 44 ++- lib/kernel/doc/src/logger_chapter.xml | 477 ++++++++++++++++++++------------ lib/kernel/doc/src/logger_formatter.xml | 370 +++++++++++++------------ 5 files changed, 682 insertions(+), 450 deletions(-) (limited to 'lib/kernel/doc/src') diff --git a/lib/kernel/doc/src/error_logger.xml b/lib/kernel/doc/src/error_logger.xml index e91fc734a4..f418aa5bbe 100644 --- a/lib/kernel/doc/src/error_logger.xml +++ b/lib/kernel/doc/src/error_logger.xml @@ -33,9 +33,10 @@ -

In OTP-21, a new API for logging was added to Erlang/OTP. The +

In Erlang/OTP 21.0, a new API for logging was added. The old error_logger module can still be used by legacy - code, but new code should use the new API instead.

+ code, but log events are redirected to the new Logger API. New + code should use the Logger API directly.

error_logger is no longer started by default, but is automatically started when an event handler is added with error_logger:add_report_handler/1,2. The error_logger @@ -89,6 +90,9 @@ The function returns ok if successful.

The event handler must be able to handle the events in this module, see section Events.

+

The first time this function is called, + error_logger is added as a Logger handler, and + the error_logger process is started.

@@ -98,37 +102,40 @@

Deletes an event handler from the error logger by calling gen_event:delete_handler(error_logger, Handler, []), see gen_event(3).

+

If no more event handlers exist after the deletion, + error_logger is removed as a Logger handler, and + the error_logger process is stopped.

- Send a standard error event to the error logger. + Log a standard error event. -

Sends a standard error event to the error logger. - The Format and Data arguments - are the same as the arguments of +

Log a standard error event. The Format + and Data arguments are the same as the + arguments of io:format/2 - in STDLIB. - The event is handled by the standard event handler.

+ in STDLIB.

+

Error logger forwards the event to Logger, including + metadata that allows backwards compatibility with legacy + error logger event handlers.

+

The event is handled by the default Logger handler.

+

These functions are kept for backwards compatibility and + must not be used by new code. Use the + ?LOG_ERROR macro or + logger:error/1,2,3 + instead.

Example:

-1> error_logger:error_msg("An error occurred in ~p~n", [a_module]).
-
-=ERROR REPORT==== 11-Aug-2005::14:03:19 ===
+1> error_logger:error_msg("An error occurred in ~p", [a_module]).
+=ERROR REPORT==== 22-May-2018::11:18:43.376917 ===
 An error occurred in a_module
 ok
- -

If called with bad arguments, this function can crash - the standard event handler, meaning no further events are - logged. When in doubt, use - error_report/1 - instead.

-

If the Unicode translation modifier (t) is used in - the format string, all error handlers must ensure that the + the format string, all event handlers must ensure that the formatted output is correctly encoded for the I/O device.

@@ -136,36 +143,51 @@ ok
- Send a standard error report event to the error logger. + Log a standard error event. -

Sends a standard error report event to the error logger. - The event is handled by the standard event handler.

+

Log a standard error event. Error logger forwards the event + to Logger, including metadata that allows backwards + compatibility with legacy error logger event handlers.

+

The event is handled by the default Logger handler.

+

This functions is kept for backwards compatibility and + must not be used by new code. Use the + ?LOG_ERROR macro or + logger:error/1,2,3 + instead.

Example:

 2> error_logger:error_report([{tag1,data1},a_term,{tag2,data}]).
-
-=ERROR REPORT==== 11-Aug-2005::13:45:41 ===
+=ERROR REPORT==== 22-May-2018::11:24:23.699306 ===
     tag1: data1
     a_term
     tag2: data
 ok
 3> error_logger:error_report("Serious error in my module").
-
-=ERROR REPORT==== 11-Aug-2005::13:45:49 ===
+=ERROR REPORT==== 22-May-2018::11:24:45.972445 ===
 Serious error in my module
 ok
- Send a user-defined error report event to the error logger. + Log a user-defined error event. -

Sends a user-defined error report event to the error logger. - An event handler to handle the event is supposed to have been - added. The event is ignored by the standard event handler.

+

Log a user-defined error event. Error logger forwards the + event to Logger, including metadata that allows backwards + compatibility with legacy error logger event handlers.

+

Error logger also adds a domain field with + value [Type] to this event's metadata, + causing the filters of the default Logger handler to discard + the event. A different Logger handler, or an error logger + event handler, must be added to handle this event.

It is recommended that Report follows the same structure as for error_report/1.

+

This functions is kept for backwards compatibility and + must not be used by new code. Use the + ?LOG_ERROR macro or + logger:error/1,2,3 + instead.

@@ -181,38 +203,41 @@ ok

The error_logger_format_depth variable is deprecated since - the logging API was - introduced in OTP-21. The variable, and this function, are - kept for backwards compatibility since they still might be - used by legacy report handlers.

+ the Logger API was + introduced in Erlang/OTP 21.0. The variable, and this + function, are kept for backwards compatibility since they + still might be used by legacy report handlers.

- Send a standard information event to the error logger. + Log a standard information event. -

Sends a standard information event to the error logger. - The Format and Data arguments - are the same as the arguments of +

Log a standard information event. The Format + and Data arguments are the same as the + arguments of io:format/2 - in STDLIB. The event is handled by the standard event handler.

+ in STDLIB.

+

Error logger forwards the event to Logger, including + metadata that allows backwards compatibility with legacy + error logger event handlers.

+

The event is handled by the default Logger handler.

+

These functions are kept for backwards compatibility and + must not be used by new code. Use the + ?LOG_INFO macro or + logger:info/1,2,3 + instead.

Example:

-1> error_logger:info_msg("Something happened in ~p~n", [a_module]).
-
-=INFO REPORT==== 11-Aug-2005::14:06:15 ===
+1> error_logger:info_msg("Something happened in ~p", [a_module]).
+=INFO REPORT==== 22-May-2018::12:03:32.612462 ===
 Something happened in a_module
 ok
- -

If called with bad arguments, this function can crash - the standard event handler, meaning no further events are - logged. When in doubt, use info_report/1 instead.

-

If the Unicode translation modifier (t) is used in - the format string, all error handlers must ensure that the + the format string, all event handlers must ensure that the formatted output is correctly encoded for the I/O device.

@@ -220,37 +245,52 @@ ok
- Send a standard information report event to the error logger. + Log a standard information event. -

Sends a standard information report event to the error - logger. The event is handled by the standard event handler.

+

Log a standard information event. Error logger forwards the + event to Logger, including metadata that allows backwards + compatibility with legacy error logger event handlers.

+

The event is handled by the default Logger handler.

+

This functions is kept for backwards compatibility and + must not be used by new code. Use the + ?LOG_INFO macro or + logger:info/1,2,3 + instead.

Example:

 2> error_logger:info_report([{tag1,data1},a_term,{tag2,data}]).
-
-=INFO REPORT==== 11-Aug-2005::13:55:09 ===
+=INFO REPORT==== 22-May-2018::12:06:35.994440 ===
     tag1: data1
     a_term
     tag2: data
 ok
 3> error_logger:info_report("Something strange happened").
-
-=INFO REPORT==== 11-Aug-2005::13:55:36 ===
+=INFO REPORT==== 22-May-2018::12:06:49.066872 ===
 Something strange happened
 ok
- Send a user-defined information report event to the error logger. + Log a user-defined information event. -

Sends a user-defined information report event to the error - logger. An event handler to handle the event is supposed to - have been added. The event is ignored by the standard event - handler.

+

Log a user-defined information event. Error logger forwards + the event to Logger, including metadata that allows + backwards compatibility with legacy error logger event + handlers.

+

Error logger also adds a domain field with + value [Type] to this event's metadata, + causing the filters of the default Logger handler to discard + the event. A different Logger handler, or an error logger + event handler, must be added to handle this event.

It is recommended that Report follows the same structure as for info_report/1.

+

This functions is kept for backwards compatibility and + must not be used by new code. Use the + ?LOG_INFO macro or + logger:info/1,2,3 + instead.

@@ -349,24 +389,27 @@ ok - Send a standard warning event to the error logger. + Log a standard warning event. -

Sends a standard warning event to the error logger. - The Format and Data arguments - are the same as the arguments of +

Log a standard warning event. The Format + and Data arguments are the same as the + arguments of io:format/2 - in STDLIB. - The event is handled by the standard event handler. It is tagged - as an error, warning, or info, see + in STDLIB.

+

Error logger forwards the event to Logger, including + metadata that allows backwards compatibility with legacy + error logger event handlers.

+

The event is handled by the default Logger handler. The log + level can be changed to error or info, see warning_map/0.

- -

If called with bad arguments, this function can crash - the standard event handler, meaning no further events are - logged. When in doubt, use warning_report/1 instead.

-
+

These functions are kept for backwards compatibility and + must not be used by new code. Use the + ?LOG_WARNING macro or + logger:warning/1,2,3 + instead.

If the Unicode translation modifier (t) is used in - the format string, all error handlers must ensure that the + the format string, all event handlers must ensure that the formatted output is correctly encoded for the I/O device.

@@ -374,24 +417,43 @@ ok
- Send a standard warning report event to the error logger. + Log a standard warning event. -

Sends a standard warning report event to the error logger. - The event is handled by the standard event handler. It is - tagged as an error, warning, or info, see +

Log a standard warning event. Error logger forwards the event + to Logger, including metadata that allows backwards + compatibility with legacy error logger event handlers.

+

The event is handled by the default Logger handler. The log + level can be changed to error or info, see warning_map/0.

+

This functions is kept for backwards compatibility and + must not be used by new code. Use the + ?LOG_WARNING macro or + logger:warning/1,2,3 + instead.

- Send a user-defined warning report event to the error logger. + Log a user-defined warning event. -

Sends a user-defined warning report event to the error - logger. An event handler to handle the event is supposed to - have been added. The event is ignored by the standard event - handler. It is tagged as an error, warning, or info, - depending on the value of +

Log a user-defined warning event. Error logger forwards the + event to Logger, including metadata that allows backwards + compatibility with legacy error logger event handlers.

+

Error logger also adds a domain field with + value [Type] to this event's metadata, + causing the filters of the default Logger handler to discard + the event. A different Logger handler, or an error logger + event handler, must be added to handle this event.

+

The log level can be changed to error or info, see warning_map/0.

+

It is recommended that Report follows the same + structure as for + warning_report/1.

+

This functions is kept for backwards compatibility and + must not be used by new code. Use the + ?LOG_WARNING macro or + logger:warning/1,2,3 + instead.

@@ -455,8 +517,9 @@ ok
See Also

gen_event(3), - log_mf_h(3) - kernel(6) + logger(3), + log_mf_h(3), + kernel(6), sasl(6)

diff --git a/lib/kernel/doc/src/kernel_app.xml b/lib/kernel/doc/src/kernel_app.xml index 0f7e95472b..e2a6d30249 100644 --- a/lib/kernel/doc/src/kernel_app.xml +++ b/lib/kernel/doc/src/kernel_app.xml @@ -481,13 +481,13 @@ MaxT = TickTime + TickTime / 4
Deprecated Configuration Parameters -

In OTP-21, a new API for logging was added to Erlang/OTP. The +

In Erlang/OTP 21.0, a new API for logging was added. The old error_logger event manager, and event handlers - running on this manager, will still work, but they are not used + running on this manager, still work, but they are no longer used by default.

The following application configuration parameters can still be - set, but they will only be used if the corresponding new logger - variables are not set.

+ set, but they are only used if the corresponding configuration + parameters for Logger are not set.

error_logger Replaced by setting the type of the default diff --git a/lib/kernel/doc/src/logger.xml b/lib/kernel/doc/src/logger.xml index bb356c5b86..c0b3d81367 100644 --- a/lib/kernel/doc/src/logger.xml +++ b/lib/kernel/doc/src/logger.xml @@ -132,6 +132,29 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro log event to the handlers. If the same keys occur, values from the log call overwrite process metadata, which in turn overwrite values set by Logger.

+

The following custom metadata keys have special meaning:

+ + domain + +

The value associated with this key is used by filters + for grouping log events originating from, for example, + specific functional + areas. See + logger_filters:domain/2 + for a description of how this field can be used.

+
+ report_cb + +

If the log message is specified as + a report(), + the report_cb key can be associated with a fun + (report callback) that converts the report to a format + string and arguments. See + section Log + Message in the User's Guide for more + information about report callbacks.

+
+
@@ -145,7 +168,7 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro filters => [] formatter => {logger_formatter,DefaultFormatterConfig} -

See the +

See the logger_formatter(3) manual page for information about the default configuration for this formatter.

@@ -978,6 +1001,25 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
+ + FModule:check_config(FConfig) -> ok | {error,term()} + Validate the given formatter configuration. + + FConfig = + formatter_config() + + +

This callback function is optional.

+

The function is called by a Logger when formatter + configuration is set or modified. The formatter must + validate the given configuration and return ok if it + is correct, and {error,term()} if it is faulty.

+

See + logger_formatter(3) + for an example implementation. logger_formatter is the + default formatter used by Logger.

+
+
FModule:format(LogEvent,FConfig) -> FormattedLogEntry Format the given log event. diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml index 3b4cafb010..a3eec7bd4b 100644 --- a/lib/kernel/doc/src/logger_chapter.xml +++ b/lib/kernel/doc/src/logger_chapter.xml @@ -30,7 +30,7 @@ logger_chapter.xml -

As of OTP-21, Erlang/OTP provides a standard API for logging +

Erlang/OTP 21.0 provides a new standard API for logging through Logger, which is part of the Kernel application. Logger consists of the API for issuing log events, and a customizable backend where log handlers, filters and @@ -65,63 +65,14 @@ Conceptual Overview - -

In accordance with the Syslog protocol, RFC-5424, eight log - levels can be specified:

- - - - Level - Integer - Description - - - emergency - 0 - system is unusable - - - alert - 1 - action must be taken immediately - - - critical - 2 - critical contidions - - - error - 3 - error conditions - - - warning - 4 - warning conditions - - - notice - 5 - normal but significant conditions - - - info - 6 - informational messages - - - debug - 7 - debug-level messages - - Log Levels -
- -

A log event passes the level check if the integer value of its - log level is less than or equal to the currently configured log - level, that is, if the event is equally or more severe than the - configured level.

+

Log levels are expressed as atoms. Internally in Logger, the + atoms are mapped to integer values, and a log event passes the + log level check if the integer value of its log level is less + than or equal to the currently configured log level. That is, + the check pases if the event is equally or more severe than the + configured level. See section Log + Level for a listing and description of all log + levels.

The global log level can be overridden by a log level configured per module. This is to, for instance, allow more verbose logging from a specific part of the system.

@@ -137,13 +88,150 @@ event to its destination. See section Handlers for more details.

-

Everything upto and including the call to the handler callbacks - is executed on the client process, that is, the process where - the log event was issued. It is up to the handler implementation - if other processes are to be involved or not.

+

Everything up to and including the call to the handler + callbacks is executed on the client process, that is, the + process where the log event was issued. It is up to the handler + implementation if other processes are involved or not.

The handlers are called in sequence, and the order is not defined.

+
+ Logger API +

The API for logging consists of a set + of macros, and a set + of functions on the form logger:Level/1,2,3, which are + all shortcuts + for + logger:log(Level,Arg1[,Arg2[,Arg3]]).

+

The difference between using the macros and the exported + functions is that macros add location (originator) information + to the metadata, and performs lazy evaluation by wrapping the + logger call in a case statement, so it is only evaluated if the + log level of the event passes the global log level check.

+
+ + Log Level +

The log level indicates the severity of a event. In + accordance with the Syslog protocol, RFC-5424, eight log + levels can be specified. The following table lists all + possible log levels by name (atom), integer value, and + description:

+ + + + Level + Integer + Description + + + emergency + 0 + system is unusable + + + alert + 1 + action must be taken immediately + + + critical + 2 + critical contidions + + + error + 3 + error conditions + + + warning + 4 + warning conditions + + + notice + 5 + normal but significant conditions + + + info + 6 + informational messages + + + debug + 7 + debug-level messages + + Log Levels +
+

Notice that the integer value is only used internally in + Logger. In the API, you must always use the atom. To compare + the severity of two log levels, + use + logger:compare_levels/2.

+
+
+ + Log Message +

The log message contains the information to be logged. The + message can consist of a format string and arguments (given as + two separate parameters in the Logger API), a string or a + report. The latter, which is either a map or a key-value list, + can be accompanied by a report callback specified in the log + event's metadata. The + report callback is a convenience function that + the formatter can use + to convert the report to a format string and arguments. The + formatter can also use its own conversion function, if no + callback is provided, or if a customized formatting is + desired.

+

Example, format string and arguments:

+ logger:error("The file does not exist: ~ts",[Filename]) +

Example, string:

+ logger:notice("Something strange happened!") +

Example, report, and metadata with report callback:

+ +logger:debug(#{got => connection_request, id => Id, state => State}, + #{report_cb => fun(R) -> {"~p",[R]} end}) +

The log message can also be provided through a fun for lazy + evaluation. The fun is only evaluated if the global log level + check passes, and is therefore recommended if it is expensive + to generate the message. The lazy fun must return a string, a + report, or a tuple with format string and arguments.

+
+
+ Metadata +

Metadata contains additional data associated with a log + message. Logger inserts some metadata fields by default, and + the client can add custom metadata in two different ways:

+ + Set process metadata + +

Process metadata is set and updated + with + logger:set_process_metadata/1 + and + logger:update_process metadata/1, + respectively. This metadata applies to the process on + which these calls are made, and Logger adds the metadata + to all log events issued on that process.

+
+ Add metadata to a specifc log event + +

Metadata associated with one specifc log event is given + as the last parameter to the log macro or Logger API + function when the event is issued. For example:

+ ?LOG_ERROR("Connection closed",#{context => server}) +
+
+

See the description of + the + logger:metadata() type for information + about which default keys Logger inserts, and how the different + metadata maps are merged.

+
+
Filters @@ -166,13 +254,13 @@ discarded. If the filter is global, no handler filters or callbacks are called. If it is a handler filter, the corresponding handler callback is not called, but the log event - is forwarded to the filters attached to the next handler, if + is forwarded to filters attached to the next handler, if any.

If the log event is returned, the next filter function is called with the returned value as the first argument. That is, if a filter function modifies the log event, the next filter - function receivea the modified event. The value returned from - the last filter funcion is the value that the handler callback + function receives the modified event. The value returned from + the last filter function is the value that the handler callback receives.

If the filter function returns ignore, it means that it did not recognize the log event, and thus leaves to other @@ -180,24 +268,21 @@

The configuration option filter_default specifies the behaviour if all filter functions - return ignore. filter_default is by default set - to log, meaning that if all filters ignore a log event, - Logger forwards the event to the handler - callback. If filter_default is set to stop, - Logger discards such events.

- -

Filters are applied in the reverse order of installation, - meaning that the last added filter is applied first.

- + return ignore, or if no filters + exist. filter_default is by default set to log, + meaning that if all existing filters ignore a log event, Logger + forwards the event to the handler + callback. If filter_default is set to stop, Logger + discards such events.

Global filters are added with logger:add_logger_filter/2 and removed with logger:remove_logger_filter/1. They can also - be added at system start via Kernel configuration + be added at system start via the Kernel configuration parameter logger.

-

Handler filters are added with +

Handler filters are added with logger:add_handler_filter/3 and removed @@ -206,7 +291,7 @@ be specified directly in the configuration when adding a handler with logger:add_handler/3 - or via Kernel configuration + or via the Kernel configuration parameter logger.

To see which filters are currently installed in the system, @@ -215,35 +300,37 @@ logger:get_logger_config/0 and logger:get_handler_config/1. Filters are - applied in the order they are listed.

+ listed in the order they are applied, that is, the first + filter in the list is applied first, and so on.

For convenience, the following built-in filters exist:

- - -

- logger_filters:domain/2 provides a way of - filtering log events based on a - domain field Metadata.

-
- -

- logger_filters:level/2 provides a way of - filtering log events based on the log level.

-
- -

- logger_filters:progress/2 stops or allows - progress reports from supervisor - and application_controller.

-
- -

- logger_filters:remote_gl/2 stops or allows - log events originating from a process that has its group - leader on a remote node.

-
-
+ + + logger_filters:domain/2 + +

Provides a way of filtering log events based on a + domain field in Metadata.

+
+ + logger_filters:level/2 + +

Provides a way of filtering log events based on the log + level.

+
+ + logger_filters:progress/2 + +

Stops or allows progress reports from supervisor + and application_controller.

+
+ + logger_filters:remote_gl/2 + +

Stops or allows log events originating from a process + that has its group leader on a remote node.

+
+
@@ -252,19 +339,19 @@

A handler is defined as a module exporting at least the following function:

-
log(LogEvent, Config)
+
log(LogEvent, Config) -> void()

This function is called when a log event has passed through all global filters, and all handler filters attached to the handler in question. The function call is executed on the client process, and it is up to the handler implementation if other - processes are to be involved or not.

+ processes are involved or not.

Logger allows adding multiple instances of a handler - callback. That is, the callback module might be implemented in - such a way that, by using different handler identities, the same - callback module can be used for multiple handler - instances. Handler configuration is per instance.

+ callback. That is, if a callback module implementation allows + it, you can add multiple handler instances using the same + callback module. The different instances are identified by + unique handler identities.

In addition to the mandatory callback function log/2, a handler module can export the optional callback @@ -281,20 +368,19 @@

This is the default handler used by OTP. Multiple instances can be started, and each instance will write log events to a - given destination, console or file. Filters can be used for - selecting which event to send to which handler instance.

+ given destination, terminal or file.

logger_disk_log_h -

This handler behaves much like logger_std_h, except it uses +

This handler behaves much like logger_std_h, except it uses disk_log as its destination.

error_logger -

This handler is to be used for backwards compatibility +

This handler is provided for backwards compatibility only. It is not started by default, but will be automatically started the first time an error_logger event handler is added @@ -302,7 +388,8 @@ error_logger:add_report_handler/1,2.

The old error_logger event handlers in STDLIB and - SASL still exist, but they are not added by Erlang/OTP.

+ SASL still exist, but they are not added by Erlang/OTP 21.0 + or later.

@@ -312,9 +399,10 @@ Formatters

A formatter can be used by the handler implementation to do the final formatting of a log event, before printing to the - handler's destination. The handler callback gets the formatter - information in the handler configuration, which is passed as the - second argument to + handler's destination. The handler callback receives the + formatter information as part of the handler configuration, + which is passed as the second argument + to HModule:log/2.

The formatter information consits of a formatter module, FModule and its @@ -322,9 +410,23 @@ following function, which can be called by the handler:

format(LogEvent,FConfig)
 	-> FormattedLogEntry
-

See the - logger_formatter(3) manual for the full - description of the default formatter used by Logger.

+

The formatter information for a handler is set as a part of its + configuration when the handler is added. It can also be changed + during runtime + with + logger:set_handler_config(HandlerId,formatter,{FModule,FConfig}) + , which overwrites the current formatter information, + or with + logger:update_formatter_config/2,3, which + only modifies the formatter configuration.

+

If the formatter module exports the optional callback + function + check_config(FConfig), Logger calls this + function when the formatter information is set or modified, to + verify the validity of the formatter configuration.

+

If no formatter information is specified for a handler, Logger + uses + logger_formatter(3) as default.

@@ -335,7 +437,7 @@ or at run-time by using the logger(3) API. The recommended approach is to do the initial configuration in the sys.config file and then use the API when some configuration - has to be changed at run-time, such as the log level.

+ has to be changed at runtime, such as the log level.

Kernel Configuration Parameters @@ -436,9 +538,9 @@ logger:level()

Specifies the global log level to log.

-

See table Log - Levels in the Overview section for a listing - and description of possible log levels.

+

See section Log + Level for a listing and description of + possible log levels.

The initial value of this option is set by the Kernel configuration parameter @@ -465,7 +567,7 @@ filter_default = log | stop

Specifies what to do with an event if all filters - return ignore.

+ return ignore, or if no filters exist.

See section Filters for more information about how this option is used.

Default is log.

@@ -481,9 +583,9 @@ logger:level()

Specifies the log level which the handler logs.

-

See table Log - Levels in the Overview section for a listing - and description of possible log levels.

+

See section Log + Level for a listing and description of + possible log levels.

The log level can be specified when adding the handler, or changed during runtime with, for instance, @@ -509,7 +611,7 @@ filter_default = log | stop

Specifies what to do with an event if all filters - return ignore.

+ return ignore, or if no filters exist.

See section Filters for more information about how this option is used.

Default is log.

@@ -553,14 +655,14 @@
Backwards Compatibility with error_logger -

Logger provides backwards compatibility with the old +

Logger provides backwards compatibility with error_logger in the following ways:

API for Logging -

The old error_logger API still exists, but should - only be used by legacy code. It will be removed in a later +

The error_logger API still exists, but should only + be used by legacy code. It will be removed in a later release.

Calls to @@ -585,7 +687,7 @@

To get log events on the same format as produced by error_logger_tty_h and error_logger_file_h, use the default formatter, logger_formatter, with - configuration parameter legacy_header=>true. This is + configuration parameter legacy_header => true. This is also the default.

Default Format of Log Events from OTP @@ -608,10 +710,11 @@ configuration parameters.

Due to the specific event handlers, the output format slightly differed from other log events.

-

As of OTP-21, the concept of SASL reports is removed, - meaning that the default behaviour is as follows:

+

As of Erlang/OTP 21.0, the concept of SASL reports is + removed, meaning that the default behaviour is as + follows:

- Supervisor reports, crash reports and progress reports + Supervisor reports, crash reports, and progress reports are no longer connected to the SASL application. Supervisor reports and crash reports are logged by default. @@ -626,15 +729,15 @@ parameter logger_sasl_compatible can be set to true. The - old SASL + SASL configuration parameters can then be used as before, and the SASL reports will only be printed if the SASL application is running, through a second log handler named sasl.

All SASL reports have a metadata - field domain=>[beam,erlang,otp,sasl], which can be + field domain => [beam,erlang,otp,sasl], which can be used, for example, by filters to stop or allow the - events.

+ log events.

See the SASL User's Guide for more information about the old SASL error logging functionality.

@@ -650,14 +753,14 @@ error_logger:add_report_handler/1,2. event manager, and add error_logger as a handler to logger, with configuration

-#{level=>info, - filter_default=>log, - filters=>[]}. +#{level => info, + filter_default => log, + filters => []}.

Notice that this handler will ignore events that do not - originate from the old error_logger API, or from - within OTP. This means that if your code uses the Logger API - for logging, then your log events will be discarded by this + originate from the error_logger API, or from within + OTP. This means that if your code uses the Logger API for + logging, then your log events will be discarded by this handler.

Also notice that error_logger is not overload protected.

@@ -676,8 +779,9 @@ error_logger:add_report_handler/1,2. arguments by the handler. If a report is given, a default report callback can be included in the log event's metadata. The handler can use this callback for converting the report to a - format string and arguments. The handler might also do a custom - conversion if the default format is not desired.

+ format string and arguments. If the format obtained by the + provided callback is not desired, or if there is no provided + callback, the handler must do a custom conversion.

Logger does, to a certain extent, check its input data before forwarding a log event to the handlers, but it does not evaluate conversion funs or check the validity of format strings @@ -686,18 +790,17 @@ error_logger:add_report_handler/1,2. that it does not crash due to bad input data or faulty callbacks.

If a filter or handler still crashes, Logger will remove the - filter or handler in question from the configuration, and then - print a short error message on the console. A debug event - containing the crash reason and other details is also issued, - and can be seen if a handler is installed which logs on debug - level.

+ filter or handler in question from the configuration, and print + a short error message to the terminal. A debug event containing + the crash reason and other details is also issued, and can be + seen if a handler logging debug events is installed.

Example: add a handler to log debug events to file -

When starting an erlang node, the default behaviour is that all +

When starting an Erlang node, the default behaviour is that all log events with level info and above are logged to the - console. In order to also log debug events, you can either + terminal. In order to also log debug events, you can either change the global log level to debug or add a separate handler to take care of this. In this example we will add a new handler which prints the debug events to a separate file.

@@ -705,28 +808,32 @@ error_logger:add_report_handler/1,2. type {file,File}, and we set the handler's level to debug:

-1> Config = #{level=>debug,logger_std_h=>#{type=>{file,"./debug.log"}}}.
+1> Config = #{level => debug, logger_std_h => #{type => {file,"./debug.log"}}}.
 #{logger_std_h => #{type => {file,"./debug.log"}},
   level => debug}
 2> logger:add_handler(debug_handler,logger_std_h,Config).
 ok

By default, the handler receives all events - (filter_defalt=log), so we need to add a filter to stop - all non-debug events:

+ (filter_default=log, see + section Filters for more + details), so we need to add a filter to stop all non-debug + events. The built-in + filter + logger_filters:level/2 + is used for this:

-3> Fun = fun(#{level:=debug}=Log,_) -> Log; (_,_) -> stop end.
-#Fun<erl_eval.12.98642416>
-4> logger:add_handler_filter(debug_handler,allow_debug,{Fun,[]}).
+3> logger:add_handler_filter(debug_handler,stop_non_debug,
+                             {fun logger_filters:level/2,{stop,neq,debug}}).
 ok

And finally, we need to make sure that Logger itself allows debug events. This can either be done by setting the global log level:

-5> logger:set_logger_config(level,debug).
+4> logger:set_logger_config(level,debug).
 ok

Or by allowing debug events from one or a few modules only:

-6> logger:set_module_level(mymodule,debug).
+5> logger:set_module_level(mymodule,debug).
 ok
@@ -736,29 +843,31 @@ ok

The only requirement that a handler MUST fulfill is to export the following function:

log(logger:log_event(),logger:config()) -> ok -

It may also implement the following callbacks:

+

It can optionally also implement the following callbacks:

adding_handler(logger:config()) -> {ok,logger:config()} | {error,term()} removing_handler(logger:config()) -> ok changing_config(logger:config(),logger:config()) -> {ok,logger:config()} | {error,term()} -

When logger:add_handler(Id,Module,Config) is called, Logger - will first call HModule:adding_handler(Config), and if it - returns {ok,NewConfig}, NewConfig is written to the - configuration database. After this, the handler may receive log - events as calls to HModule:log/2.

+

When logger:add_handler(Id,Module,Config) is called, + Logger first calls HModule:adding_handler(Config). If + this function returns {ok,NewConfig}, Logger + writes NewConfig to the configuration database, and + the logger:add_handler/3 call returns. After this, the + handler is installed and must be ready to receive log events as + calls to HModule:log/2.

A handler can be removed by calling - logger:remove_handler(Id). Logger will call - HModule:removing_handler(Config), and then remove the + logger:remove_handler(Id). Logger calls + HModule:removing_handler(Config), and removes the handler's configuration from the configuration database.

When logger:set_handler_config/2,3 - or logger:update_handler_config/2 are called, Logger + or logger:update_handler_config/2 is called, Logger calls HModule:changing_config(OldConfig,NewConfig). If - this function returns {ok,NewConfig}, NewConfig is - written to the configuration database.

+ this function returns {ok,NewConfig}, Logger + writes NewConfig to the configuration database.

-

A simple handler that prints to the console could be - implemented as follows:

+

A simple handler that prints to the terminal can be implemented + as follows:

-module(myhandler). -export([log/2]). @@ -776,7 +885,7 @@ log(LogEvent,#{formatter:={FModule,FConfig}) -> adding_handler(Config) -> {ok,Fd} = file:open(File,[append,{encoding,utf8}]), - {ok,Config#{myhandler_fd=>Fd}}. + {ok,Config#{myhandler_fd => Fd}}. removing_handler(#{myhandler_fd:=Fd}) -> _ = file:close(Fd), @@ -790,10 +899,12 @@ log(LogEvent,#{myhandler_fd:=Fd,formatter:={FModule,FConfig}}) -> protection, and all log events are printed directly from the client process.

-

For examples of overload protection, please refer to the - implementation - of logger_std_h - and logger_disk_log_h +

For information and examples of overload protection, please + refer to + section Protecting the + Handler from Overload, and the implementation + of logger_std_h(3) + and logger_disk_log_h(3) .

Below is a simpler example of a handler which logs through one @@ -805,7 +916,7 @@ log(LogEvent,#{myhandler_fd:=Fd,formatter:={FModule,FConfig}}) -> adding_handler(Config) -> {ok,Pid} = gen_server:start(?MODULE,Config), - {ok,Config#{myhandler_pid=>Pid}}. + {ok,Config#{myhandler_pid => Pid}}. removing_handler(#{myhandler_pid:=Pid}) -> gen_server:stop(Pid). @@ -815,7 +926,7 @@ log(LogEvent,#{myhandler_pid:=Pid} = Config) -> init(#{myhandler_file:=File}) -> {ok,Fd} = file:open(File,[append,{encoding,utf8}]), - {ok,#{file=>File,fd=>Fd}}. + {ok,#{file => File, fd => Fd}}. handle_call(_,_,State) -> {reply,{error,bad_request},State}. @@ -949,7 +1060,7 @@ logger:add_handler(my_standard_h, logger_std_h, both built-in handlers offer the possibility to set a maximum level of how many requests to process with a certain time frame. With this burst control feature enabled, the handler will take care of bursts of log requests - without choking log files, or the console, with massive amounts of + without choking log files, or the terminal, with massive amounts of printouts. These are the configuration parameters:

diff --git a/lib/kernel/doc/src/logger_formatter.xml b/lib/kernel/doc/src/logger_formatter.xml index ee43634cf9..02f89b26be 100644 --- a/lib/kernel/doc/src/logger_formatter.xml +++ b/lib/kernel/doc/src/logger_formatter.xml @@ -46,97 +46,150 @@ Logger.

-
- Configuration -

The configuration term for logger_formatter is a - map, - and the following keys can be set as configuration - parameters:

- - chars_limit = pos_integer() | unlimited - -

A positive integer representing the value of the option - with the same name to be used when calling - io_lib:format/3. - This value limits the total number of characters printed - for each log event. Notice that this is a soft limit. For a - hard truncation limit, see option max_size.

-

Default is unlimited.

- -

chars_limit has no effect on log messages on - string form. These are expected to be short, but can still - be truncated by the max_size parameter.

-
-
- depth = pos_integer() | unlimited - -

A positive integer representing the maximum depth to - which terms shall be printed by this formatter. Format - strings passed to this formatter are rewritten. The format - controls ~p and ~w are replaced with ~P and ~W, - respectively, and the value is used as the depth - parameter. For details, see - io:format/2,3 - in STDLIB.

-

Default is unlimited.

- -

depth has no effect on log messages on string - form. These are expected to be short, but can still be - truncated by the max_size parameter.

-
-
- max_size = pos_integer() | unlimited - -

A positive integer representing the absolute maximum size a - string returned from this formatter can have. If the - formatted string is longer, after possibly being limited - by chars_limit or depth, it is truncated.

-

Default is unlimited.

-
- single_line = boolean() - -

If set to true, all newlines in the message are - replaced with ", ", and whitespaces following - directly after newlines are removed. Note that newlines - added by the template parameter are not replaced.

-

Default is true.

-
- legacy_header = boolean() - -

If set to true a header field is added to - logger_formatter's part of Metadata. The value of - this field is a string similar to the header created by the - old error_logger event handlers. It can be included - in the log event by adding the - tuple {logger_formatter,header} to the template. See - section Default - Templates for more information.

-

Default is false.

-
- report_cb = fun((logger:report()) -> {io:format(),[term()]}) - -

A report callback is used by the formatter to transform log - messages on report form to a format string and - arguments. The report callback can be specified in the - metadata for the log event. If no report callback exist in - metadata, logger_formatter will - use - logger:format_report/1 as default - callback.

-

If this configuration parameter is set, it replaces both - the default report callback, and any report callback found - in metadata. That is, all reports are converted by this - configured function.

-

The value must be a function with arity 1, - returning {Format,Args}, and it will be called with a - report as only argument.

-
- template = template() - + + + + + +

The configuration term for logger_formatter is a + map, and the + following keys can be set as configuration parameters:

+ + chars_limit = pos_integer() | unlimited + +

A positive integer representing the value of the option + with the same name to be used when calling + + io_lib:format/3. + This value limits the total number of characters printed + for each log event. Notice that this is a soft limit. For a + hard truncation limit, see option max_size.

+

Defaults to unlimited.

+ +

chars_limit has no effect on log messages on + string form. These are expected to be short, but can + still be truncated by the max_size + parameter.

+
+
+ depth = pos_integer() | unlimited + +

A positive integer representing the maximum depth to + which terms shall be printed by this formatter. Format + strings passed to this formatter are rewritten. The + format controls ~p and ~w are replaced with ~P and ~W, + respectively, and the value is used as the depth + parameter. For details, see + io:format/2,3 + in STDLIB.

+

Defaults to unlimited.

+ +

depth has no effect on log messages on string + form. These are expected to be short, but can still be + truncated by the max_size parameter.

+
+
+ legacy_header = boolean() + +

If set to true a header field is added to + logger_formatter's part of Metadata. The value of + this field is a string similar to the header created by + the old error_logger event handlers. It can be + included in the log event by adding the + tuple {logger_formatter,header} to the + template. See the description of + the template() + type for more information.

+

Defaults to false.

+
+ max_size = pos_integer() | unlimited + +

A positive integer representing the absolute maximum size a + string returned from this formatter can have. If the + formatted string is longer, after possibly being limited + by chars_limit or depth, it is truncated.

+

Defaults to unlimited.

+
+ report_cb = fun((logger:report()) -> {io:format(),[term()]}) + +

A report callback is used by the formatter to transform + log messages on report form to a format string and + arguments. The report callback can be specified in the + metadata for the log event. If no report callback exist + in metadata, logger_formatter will + use + logger:format_report/1 as default + callback.

+

If this configuration parameter is set, it replaces + both the default report callback, and any report + callback found in metadata. That is, all reports are + converted by this configured function.

+

The value must be a function with arity 1, + returning {Format,Args}, and it will be called + with a report as only argument.

+
+ single_line = boolean() + +

If set to true, all newlines in the message are + replaced with ", ", and whitespaces following + directly after newlines are removed. Note that newlines + added by the template parameter are not replaced.

+

Defaults to true.

+
+ template = template() + +

The template describes how the formatted string is + composed by combining different data values from the log + event. See the description of + the template() + type for more information about this.

+
+ time_designator = byte() + +

Timestamps are formatted according to RFC3339, and the + time designator is the character used as date and time + separator.

+

Defaults to $T.

+

The value of this parameter is used as + the time_designator option + to + calendar:system_time_to_rcf3339/2.

+
+ time_offset = integer() | [byte()] + +

The time offset, either a string or an integer, to be + used when formatting the timestamp.

+

An empty string is interpreted as local time. The + values "Z", "z" or 0 are + interpreted as Universal Coordinated Time (UTC).

+

Strings, other than "Z", "z", + or "", must be on the form ±[hh]:[mm], for + example "-02:00" or "+00:00".

+

Integers must be in microseconds, meaning that the + offset 7200000000 is equivalent + to "+02:00".

+

Defaults to an empty string, meaning that timestamps + are displayed in local time. However, for backwards + compatibility, if the SASL configuration + parameter + utc_log=true, the default is + changed to "Z", meaning that timestamps are displayed + in UTC.

+

The value of this parameter is used as + the offset option + to + calendar:system_time_to_rcf3339/2.

+
+
+
+
+ + +

The template is a list of atoms, tuples and strings. The atoms level or msg, are treated as placeholders for the severity level and the log message, - repectively. Other atoms or tuples are interpreted as + respectively. Other atoms or tuples are interpreted as placeholders for metadata, where atoms are expected to match top level keys, and tuples represent paths to sub keys when the metadata is a nested map. For example the @@ -154,120 +207,84 @@

Strings in the template are printed literally.

The default template differs depending on the values of legacy_header - and single_line. See Default - Templates for more information

-
- time_designator = byte() - -

Timestamps are formatted according to RFC3339, and the time - designator is the character used as date and time - separator.

-

Default is $T.

-

The value of this parameter is used as - the time_designator option - to - calendar:system_time_to_rcf3339/2.

-
- time_offset = integer() | [byte()] - -

The time offset, either a string or an integer, to be - used when formatting the timestamp.

-

An empty string is interpreted as local time. The - values "Z", "z" or 0 are interpreted as - Universal Coordinated Time (UTC).

-

Strings, other than "Z", "z", or "", - must be on the form ±[hh]:[mm], for - example "-02:00" or "+00:00".

-

Integers must be in microseconds, meaning that the - offset 7200000000 is equivalent - to "+02:00".

-

The default value is an empty string, meaning that - timestamps are displayed in local time. However, for - backwards compatibility, if the SASL configuration - parameter - utc_log=true, the default is - changed to "Z", meaning that timestamps are displayed - in UTC.

-

The value of this parameter is used as the offset - option to - calendar:system_time_to_rcf3339/2.

-
-
-
- -
- - Default templates + and single_line:

-

The default value for the template configuration - parameter depends on the value of single_line - and legacy_header as follows.

+

The default value for the template configuration + parameter depends on the value of the single_line + and legacy_header configuration parameters as + follows.

-

The log event used in the examples is:

- +

The log event used in the examples is:

+ ?LOG_ERROR("name: ~p~nexit_reason: ~p",[my_name,"It crashed"]) - - legacy_header=true, single_line=false - -

Default template: [{logger_formatter,header},"\n",msg,"\n"]

+ + legacy_header=true, single_line=false + +

Default + template: [{logger_formatter,header},"\n",msg,"\n"]

-

Example log entry:

- +

Example log entry:

+ =ERROR REPORT==== 17-May-2018::18:30:19.453447 === name: my_name exit_reason: "It crashed" -

Notice that all eight levels can occur in the heading, - not only ERROR, WARNING or INFO as the - old error_logger produced. And microseconds are - added at the end of the timestamp.

-
+

Notice that all eight levels can occur in the heading, + not only ERROR, WARNING or INFO as the + old error_logger produced. And microseconds are + added at the end of the timestamp.

+
- legacy_header=true, single_line=true - -

Default template: [{logger_formatter,header},"\n",msg,"\n"]

+ legacy_header=true, single_line=true + +

Default + template: [{logger_formatter,header},"\n",msg,"\n"]

-

Notice that the template is here the same as - for single_line=false, but the resulting log entry - differs in that there is only one line after the - heading:

- +

Notice that the template is here the same as + for single_line=false, but the resulting log entry + differs in that there is only one line after the + heading:

+ =ERROR REPORT==== 17-May-2018::18:31:06.952665 === name: my_name, exit_reason: "It crashed" -
+
- legacy_header=false, single_line=true - -

Default template: [time," ",level,": ",msg,"\n"]

+ legacy_header=false, single_line=true + +

Default template: [time," ",level,": ",msg,"\n"]

-

Example log entry:

- +

Example log entry:

+ 2018-05-17T18:31:31.152864+02:00 error: name: my_name, exit_reason: "It crashed" -
+
- legacy_header=false, single_line=false - -

Default template: [time," ",level,":\n",msg,"\n"]

+ legacy_header=false, single_line=false + +

Default template: [time," ",level,":\n",msg,"\n"]

-

Example log entry:

- +

Example log entry:

+ 2018-05-17T18:32:20.105422+02:00 error: name: my_name exit_reason: "It crashed" -
-
-
- - - - - +
+ + + + Validates the given formatter configuration. + +

This callback function is called by Logger when the + formatter configuration for a handler is set or modified. It + returns ok if the configuration is valid, + and {error,term()} if it is faulty.

+
+
Formats the given message. @@ -290,7 +307,6 @@ exit_reason: "It crashed"
- -- cgit v1.2.3