aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/doc/src
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2018-06-12 14:06:46 +0200
committerGitHub <[email protected]>2018-06-12 14:06:46 +0200
commit465d2849ed0d832577a25a52f0717ec5f7eb94bd (patch)
tree490304495c0562d34dc4fb7415a64deafd25f470 /lib/kernel/doc/src
parent0f752d6e9cb447552673bddebccab31539e55358 (diff)
parent8ae3b6289f25e6c283be5b0d67cd5f6c4434b6e2 (diff)
downloadotp-465d2849ed0d832577a25a52f0717ec5f7eb94bd.tar.gz
otp-465d2849ed0d832577a25a52f0717ec5f7eb94bd.tar.bz2
otp-465d2849ed0d832577a25a52f0717ec5f7eb94bd.zip
Merge pull request #1835 from sirihansen/siri/logger-fix
Diffstat (limited to 'lib/kernel/doc/src')
-rw-r--r--lib/kernel/doc/src/error_logger.xml35
-rw-r--r--lib/kernel/doc/src/kernel_app.xml117
-rw-r--r--lib/kernel/doc/src/logger.xml883
-rw-r--r--lib/kernel/doc/src/logger_arch.pngbin32377 -> 32407 bytes
-rw-r--r--lib/kernel/doc/src/logger_chapter.xml843
-rw-r--r--lib/kernel/doc/src/logger_disk_log_h.xml20
-rw-r--r--lib/kernel/doc/src/logger_filters.xml164
-rw-r--r--lib/kernel/doc/src/logger_formatter.xml148
-rw-r--r--lib/kernel/doc/src/logger_std_h.xml21
-rw-r--r--lib/kernel/doc/src/part.xml11
10 files changed, 1267 insertions, 975 deletions
diff --git a/lib/kernel/doc/src/error_logger.xml b/lib/kernel/doc/src/error_logger.xml
index f418aa5bbe..27fb1488c7 100644
--- a/lib/kernel/doc/src/error_logger.xml
+++ b/lib/kernel/doc/src/error_logger.xml
@@ -305,14 +305,22 @@ ok</pre>
<type name="open_error"/>
<desc>
<p>Enables or disables printout of standard events to a file.</p>
- <p>This is done by adding or deleting the standard event handler
- for output to file. Thus, calling this function overrides
- the value of the Kernel <c>error_logger</c> configuration
- parameter.</p>
- <p>Enabling file logging can be used together with calling
- <c>tty(false)</c>, to have a silent system where
- all standard events are logged to a file only.
- Only one log file can be active at a time.</p>
+ <p>This is done by adding or deleting
+ the <c>error_logger_file_h</c> event handler, and thus
+ indirectly adding <c>error_logger</c> as a Logger
+ handler.</p>
+ <p>Notice that this function does not manipulate the Logger
+ configuration directly, meaning that if the default Logger
+ handler is already logging to a file, this function can
+ potentially cause logging to a second file.</p>
+ <p>This function is useful as a shortcut during development
+ and testing, but must not be used in a production
+ system. See
+ section <seealso marker="logger_chapter">Logging</seealso>
+ in the Kernel User's Guide, and
+ the <seealso marker="logger"><c>logger(3)</c></seealso>
+ manual page for information about how to configure Logger
+ for live systems.</p>
<p><c>Request</c> is one of the following:</p>
<taglist>
<tag><c>{open, <anno>Filename</anno>}</c></tag>
@@ -344,9 +352,14 @@ ok</pre>
<p>Enables (<c><anno>Flag</anno> == true</c>) or disables
(<c><anno>Flag</anno> == false</c>) printout of standard events
to the terminal.</p>
- <p>This is done by adding or deleting the standard event handler
- for output to the terminal. Thus, calling this function overrides
- the value of the Kernel <c>error_logger</c> configuration parameter.</p>
+ <p>This is done by manipulating the Logger configuration. The
+ function is useful as a shortcut during development and
+ testing, but must not be used in a production system. See
+ section <seealso marker="logger_chapter">Logging</seealso>
+ in the Kernel User's Guide, and
+ the <seealso marker="logger"><c>logger(3)</c></seealso>
+ manual page for information about how to configure Logger
+ for live systems.</p>
</desc>
</func>
<func>
diff --git a/lib/kernel/doc/src/kernel_app.xml b/lib/kernel/doc/src/kernel_app.xml
index e2a6d30249..3914226a3e 100644
--- a/lib/kernel/doc/src/kernel_app.xml
+++ b/lib/kernel/doc/src/kernel_app.xml
@@ -54,9 +54,9 @@
<p>Two standard logger handlers are defined in
the Kernel application. These are described in the
<seealso marker="logger_chapter">Kernel User's Guide</seealso>,
- and in <seealso marker="logger_std_h"><c>logger_std_h(3)</c></seealso>
+ and in the <seealso marker="logger_std_h"><c>logger_std_h(3)</c></seealso>
and <seealso marker="logger_disk_log_h"><c>logger_disk_log_h(3)</c>
- </seealso>.</p>
+ </seealso> manual pages.</p>
</section>
<section>
@@ -166,57 +166,71 @@
</item>
<tag><marker id="logger"/><c>logger = [Config]</c></tag>
<item>
- <p>Specifies how <seealso marker="logger"><c>logger</c></seealso> should be
- configured.</p>
- <p>For more details and examples, see the <seealso marker="logger_chapter#logger">
- Configuration</seealso> section in the <seealso marker="logger_chapter">
- Logger User's Guide</seealso>.
- </p>
+ <p>Specifies the configuration
+ for <seealso marker="logger">Logger</seealso>, except the
+ primary log level, which is specified
+ with <seealso marker="#logger_level"><c>logger_level</c></seealso>,
+ and the compatibility
+ with <seealso marker="sasl:error_logging">SASL Error
+ Logging</seealso>, which is specified
+ with <seealso marker="#logger_sasl_compatible">
+ <c>logger_sasl_compatible</c></seealso>.</p>
+ <p>The <c>logger </c> parameter is described in
+ section <seealso marker="logger_chapter#logger_parameter">
+ Logging</seealso> in the Kernel User's Guide.</p>
</item>
<tag><marker id="logger_level"/><c>logger_level = Level</c></tag>
<item>
- <p><c>Level = emergency | alert | critical | error | warning |
- notice | info | debug</c></p>
- <p>This parameter specifies which log levels to log. The
- specified level, and all levels that are more severe, will
- be logged.</p>
- <p>The default value is <c>info</c>.</p>
- <p>To change the global log level at run-time, use
- <seealso marker="logger#set_logger_config/2">
- <c>logger:set_logger_config(level, error)</c></seealso>.</p>
+ <p>Specifies the primary log level for Logger. Log events with
+ the same, or a more severe level, pass through the primary
+ log level check. See
+ section <seealso marker="logger_chapter">Logging</seealso>
+ in the Kernel User's Guide for more information about Logger
+ and log levels.</p>
+ <p><c>Level = emergency | alert | critical | error | warning |
+ notice | info | debug | all | none</c></p>
+ <p>To change the primary log level at runtime, use
+ <seealso marker="logger#set_primary_config/2">
+ <c>logger:set_primary_config(level, Level)</c></seealso>.</p>
+ <p>Defaults to <c>info</c>.</p>
</item>
<tag><marker id="logger_sasl_compatible"/>
- <c>logger_sasl_compatible = boolean()</c></tag>
- <item>
- <p>If this parameter is set to true, then the <c>default</c> logger handler
- 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 <c>sasl</c>, according to values of the SASL
- configuration parameter <c>sasl_error_logger</c>
- and <c>sasl_errlog_type</c>, see
- <seealso marker="sasl:sasl_app#deprecated_error_logger_config">sasl(6)
- </seealso></p>
- <p>The default value is <c>false</c>.</p>
- <p>See chapter <seealso marker="logger_chapter#compatibility">Backwards
- compatibility with error_logger</seealso> for more
- information about handling of the so called SASL reports.</p>
- <note><p>This configuration option only effects the <c>default</c>
- and <c>sasl</c> handler. Any other handlers are uneffected.</p></note>
- </item>
- <tag><marker id="logger_progress_reports"/>
- <c>logger_progress_reports = stop | log</c></tag>
- <item>
- <p>If <c>logger_sasl_compatible = false</c>,
- then <c>logger_progress_reports</c> specifies if progress
- reports from <c>supervisor</c>
- and <c>application_controller</c> shall be logged by the
- default logger.</p>
- <p>If <c>logger_sasl_compatible = true</c>,
- then <c>logger_progress_reports</c> is ignored.</p>
- <p>The default value is <c>stop</c></p>
- <note><p>This configuration option only effects the <c>default</c>
- and <c>sasl</c> handler. Any other handlers are uneffected.</p></note>
+ <c>logger_sasl_compatible = true | false</c></tag>
+ <item>
+ <p>Specifies if Logger behaves backwards compatible with the
+ SASL error logging functionality from releases prior to
+ Erlang/OTP 21.0.</p>
+ <p>If this parameter is set to <c>true</c>, the default Logger
+ handler does not log any progress-, crash-, or supervisor
+ reports. If the SASL application is then started, it adds a
+ Logger handler named <c>sasl</c>, which logs these events
+ according to values of the SASL configuration
+ parameter <c>sasl_error_logger</c>
+ and <c>sasl_errlog_type</c>.</p>
+ <p>See section
+ <seealso marker="sasl:sasl_app#deprecated_error_logger_config">
+ Deprecated Error Logger Event Handlers and
+ Configuration</seealso> in the sasl(6) manual page for
+ information about the SASL configuration parameters.</p>
+ <p>See section <seealso marker="sasl:error_logging">SASL Error
+ Logging</seealso> in the SASL User's Guide, and
+ section <seealso marker="logger_chapter#compatibility">Backwards
+ Compatibility with error_logger</seealso> in the Kernel
+ User's Guide for information about the SASL error logging
+ functionality, and how Logger can be backwards compatible
+ with this.</p>
+ <p>Defaults to <c>false</c>.</p>
+ <note>
+ <p>If this parameter is set to <c>true</c>,
+ <c>sasl_errlog_type</c> indicates that progress reports
+ shall be logged, and the configured primary log level
+ is <c>notice</c> or more severe, then SASL automatically
+ sets the primary log level to <c>info</c>. That is, this
+ setting can potentially overwrite the value of the Kernel
+ configuration parameter <c>logger_level</c>. This is to
+ allow progress reports, which have log level <c>info</c>,
+ to be forwarded to the handlers.</p>
+ </note>
</item>
<tag><c>global_groups = [GroupTuple]</c></tag>
<item>
@@ -269,9 +283,8 @@
</item>
<tag><c>inet_parse_error_log = silent</c></tag>
<item>
- <p>If set, no
- <c>logger</c> messages are generated when erroneous
- lines are found and skipped in the various Inet configuration
+ <p>If set, no log events are issued when erroneous lines are
+ found and skipped in the various Inet configuration
files.</p>
</item>
<tag><c>inetrc = Filename</c></tag>
@@ -494,7 +507,7 @@ MaxT = TickTime + TickTime / 4</code>
<seealso marker="logger_std_h#type"><c>logger_std_h</c></seealso>
to the same value. Example:
<code type="none">
-erl -kernel logger '[{handler,default,logger_std_h,#{logger_std_h=>#{type=>{file,"/tmp/erlang.log"}}}}]'
+erl -kernel logger '[{handler,default,logger_std_h,#{config=>#{type=>{file,"/tmp/erlang.log"}}}}]'
</code>
</item>
<tag><c>error_logger_format_depth</c></tag>
diff --git a/lib/kernel/doc/src/logger.xml b/lib/kernel/doc/src/logger.xml
index 911eb158da..7f35a5d752 100644
--- a/lib/kernel/doc/src/logger.xml
+++ b/lib/kernel/doc/src/logger.xml
@@ -33,73 +33,150 @@
<file>logger.xml</file>
</header>
<module>logger</module>
- <modulesummary>API module for logging in Erlang/OTP.</modulesummary>
+ <modulesummary>API module for Logger, the standard logging facility
+ in Erlang/OTP.</modulesummary>
<description>
- <p>
- 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 <seealso marker="#emergency-1">API functions</seealso> or the log
- <seealso marker="#macros">macros</seealso> to log events. For instance,
- to log a new error event:</p>
- <code>
-?LOG_ERROR("error happened because: ~p",[Reason]). %% With macro
-logger:error("error happened because: ~p",[Reason]). %% Without macro
- </code>
- <p>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
- must configure the default handler to do so. The simplest way is
- to include the following in your <seealso marker="config"><c>sys.config</c></seealso>.</p>
+ <p>This module implements the main API for logging in
+ Erlang/OTP. To create a log event, use the
+ <seealso marker="#logging_API">API functions</seealso> or the
+ log
+ <seealso marker="#macros">macros</seealso>, for example:</p>
+ <code>
+?LOG_ERROR("error happened because: ~p", [Reason]). % With macro
+logger:error("error happened because: ~p", [Reason]). % Without macro
+ </code>
+ <p>To configure the Logger backend,
+ use <seealso marker="kernel_app#logger">Kernel configuration
+ parameters</seealso>
+ or <seealso marker="#configuration_API">configuration
+ functions</seealso> in the Logger API.</p>
+
+ <p>By default, the Kernel application installs one log handler at
+ system start. This handler is named <c>default</c>. 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 printed to the
+ terminal.</p>
+ <p>If you want your systems logs to be printed to a file instead,
+ you must configure the default handler to do so. The simplest
+ way is to include the following in
+ your <seealso marker="config"><c>sys.config</c></seealso>:</p>
<code>
[{kernel,
[{logger,
- [{handler,default,logger_std_h,
- #{logger_std_h=>#{type=>{file,"path/to/file.log"}}}}]}]}].
+ [{handler, default, logger_std_h,
+ #{config => #{type => {file, "path/to/file.log"}}}}]}]}].
</code>
<p>
For more information about:
</p>
<list type="bulleted">
- <item>how to use the API,
- see <seealso marker="logger_chapter">the User's Guide</seealso>.</item>
- <item>how to configure Logger,
- see the <seealso marker="logger_chapter#configuration">Configuration</seealso>
+ <item>the Logger facility in general, see
+ the <seealso marker="logger_chapter">User's
+ Guide</seealso>.</item>
+ <item>how to configure Logger, see
+ the <seealso marker="logger_chapter#configuration">Configuration</seealso>
section in the User's Guide.</item>
- <item>the convinience macros in logger.hrl,
- see <seealso marker="#macros">the macro section</seealso>.</item>
- <item>what the builtin formatter can do,
- see <seealso marker="logger_formatter">logger_formatter</seealso>.</item>
- <item>what the builtin handlers can do,
+ <item>the built-in handlers,
see <seealso marker="logger_std_h">logger_std_h</seealso> and
<seealso marker="logger_disk_log_h">logger_disk_log_h</seealso>.</item>
- <item>what builtin filters are available,
+ <item>the built-in formatter,
+ see <seealso marker="logger_formatter">logger_formatter</seealso>.</item>
+ <item>built-in filters,
see <seealso marker="logger_filters">logger_filters</seealso>.</item>
</list>
</description>
<datatypes>
<datatype>
- <name name="level"/>
+ <name name="primary_config"/>
<desc>
- <p>The severity level for the message to be logged.</p>
+ <p>Primary configuration data for Logger. The following
+ default values apply:</p>
+ <list>
+ <item><c>level => info</c></item>
+ <item><c>filter_default => log</c></item>
+ <item><c>filters => []</c></item>
+ </list>
</desc>
</datatype>
<datatype>
- <name name="log_event"/>
+ <name name="handler_config"/>
<desc>
- <p></p>
+ <p>Handler configuration data for Logger. The following
+ default values apply:</p>
+ <list>
+ <item><c>level => all</c></item>
+ <item><c>filter_default => log</c></item>
+ <item><c>filters => []</c></item>
+ <item><c>formatter => {logger_formatter, DefaultFormatterConfig</c>}</item>
+ </list>
+ <p>In addition to these, the following fields are
+ automatically inserted by Logger, values taken from the
+ two first parameters
+ to <seealso marker="#add_handler-3"><c>add_handler/3</c></seealso>:</p>
+ <list>
+ <item><c>id => HandlerId</c></item>
+ <item><c>module => Module</c></item>
+ </list>
+ <p>Handler specific configuration data is inserted by the
+ handler callback itself, in a sub structure associated with
+ the field named <c>config</c>.</p>
+ <p>See the <seealso marker="logger_formatter#type-config">
+ <c>logger_formatter(3)</c></seealso> manual page for
+ information about the default configuration for this
+ formatter.</p>
</desc>
</datatype>
<datatype>
- <name name="report"/>
+ <name name="filter"/>
<desc>
- <p></p>
+ <p>A filter which can be installed as a handler filter, or as
+ a primary filter in Logger.</p>
</desc>
</datatype>
<datatype>
- <name name="msg_fun"/>
+ <name name="filter_arg"/>
+ <desc>
+ <p>The second argument to the filter fun.</p>
+ </desc>
+ </datatype>
+ <datatype>
+ <name name="filter_id"/>
+ <desc>
+ <p>A unique identifier for a filter.</p>
+ </desc>
+ </datatype>
+ <datatype>
+ <name name="filter_return"/>
+ <desc>
+ <p>The return value from the filter fun.</p>
+ </desc>
+ </datatype>
+ <datatype>
+ <name name="formatter_config"/>
+ <desc>
+ <p>Configuration data for the
+ formatter. See <seealso marker="logger_formatter">
+ <c>logger_formatter(3)</c></seealso>
+ for an example of a formatter implementation.</p>
+ </desc>
+ </datatype>
+ <datatype>
+ <name name="handler_id"/>
+ <desc>
+ <p>A unique identifier for a handler instance.</p>
+ </desc>
+ </datatype>
+ <datatype>
+ <name name="level"/>
+ <desc>
+ <p>The severity level for the message to be logged.</p>
+ </desc>
+ </datatype>
+ <datatype>
+ <name name="log_event"/>
<desc>
<p></p>
</desc>
@@ -117,7 +194,7 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro
<p>When a log macro is used, Logger also inserts location
information:</p>
<list>
- <item><c>mfa => {?MODULE,?FUNCTION_NAME,?FUNCTION_ARITY}</c></item>
+ <item><c>mfa => {?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY}</c></item>
<item><c>file => ?FILE</c></item>
<item><c>line => ?LINE</c></item>
</list>
@@ -158,51 +235,15 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro
</desc>
</datatype>
<datatype>
- <name name="config"/>
- <desc>
- <p>Configuration data for the logger part of Logger, or for a handler.</p>
- <p>The following default values apply:</p>
- <list>
- <item><c>level => info</c></item>
- <item><c>filter_default => log</c></item>
- <item><c>filters => []</c></item>
- <item><c>formatter => {logger_formatter,DefaultFormatterConfig</c>}</item>
- </list>
- <p>See the <seealso marker="logger_formatter#type-config">
- <c>logger_formatter(3)</c></seealso> manual page for
- information about the default configuration for this
- formatter.</p>
- </desc>
- </datatype>
- <datatype>
- <name name="handler_id"/>
- <desc>
- <p>A unique identifier for a handler instance.</p>
- </desc>
- </datatype>
- <datatype>
- <name name="filter_id"/>
- <desc>
- <p>A unique identifier for a filter.</p>
- </desc>
- </datatype>
- <datatype>
- <name name="filter"/>
- <desc>
- <p>A filter which can be installed for the logger part of
- Logger, or for a handler.</p>
- </desc>
- </datatype>
- <datatype>
- <name name="filter_arg"/>
+ <name name="msg_fun"/>
<desc>
- <p>The second argument to the filter fun.</p>
+ <p></p>
</desc>
</datatype>
<datatype>
- <name name="filter_return"/>
+ <name name="report"/>
<desc>
- <p>The return value from the filter fun.</p>
+ <p></p>
</desc>
</datatype>
<datatype>
@@ -213,15 +254,6 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro
<c>erlang:system_time(microsecond)</c></seealso>.</p>
</desc>
</datatype>
- <datatype>
- <name name="formatter_config"/>
- <desc>
- <p>Configuration data for the
- formatter. See <seealso marker="logger_formatter">
- <c>logger_formatter(3)</c></seealso>
- for an example of a formatter implementation.</p>
- </desc>
- </datatype>
</datatypes>
<section>
@@ -258,6 +290,10 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro
level.</p>
</section>
+ <section>
+ <marker id="logging_API"/>
+ <title>Logging API functions</title>
+ </section>
<funcs>
<func>
<name>emergency(StringOrReport[,Metadata])</name>
@@ -317,7 +353,7 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro
<func>
<name>notice(StringOrReport[,Metadata])</name>
<name>notice(Format,Args[,Metadata])</name>
- <name>notice(Fun,FunArgs[,Metadata])</name>
+ <name>notice(Fun,FunArgs[,Metadata])</name>
<fsummary>Logs the given message as level <c>notice</c>.</fsummary>
<desc>
<p>Equivalent to
@@ -366,136 +402,21 @@ logger:error("error happened because: ~p",[Reason]). %% Without macro
<p>Log the given message.</p>
</desc>
</func>
+ </funcs>
+ <section>
+ <marker id="configuration_API"/>
+ <title>Configuration API functions</title>
+ </section>
+ <funcs>
<func>
- <name name="get_logger_config" arity="0"/>
- <fsummary>Look up the current configuration for the logger part
- of Logger.</fsummary>
- <desc>
- <p>Look up the current configuration for the logger part of
- Logger.</p>
- </desc>
- </func>
-
- <func>
- <name name="get_handler_config" arity="1"/>
- <fsummary>Look up the current configuration for the given
- handler.</fsummary>
- <desc>
- <p>Look up the current configuration for the given handler.</p>
- </desc>
- </func>
-
- <func>
- <name name="i" arity="0"/>
- <fsummary>Get all Logger configurations</fsummary>
- <desc>
- <p>Same as <seealso marker="#i/1"><c>logger:i(term)</c></seealso></p>
- </desc>
- </func>
-
- <func>
- <name name="i" arity="1" clause_i="1"/>
- <name name="i" arity="1" clause_i="2"/>
- <name name="i" arity="1" clause_i="3"/>
- <fsummary>Get all Logger configurations</fsummary>
- <desc>
- <p>Display or return all current Logger configurations.</p>
- <taglist>
- <tag><c><anno>Action</anno> = string</c></tag>
- <item>
- <p>Return the pretty printed current Logger configuration
- as iodata.</p>
- </item>
- <tag><c><anno>Action</anno> = term</c></tag>
- <item>
- <p>Return the current Logger configuration as a term. The
- format of this term may change between releases. For a
- stable format use <seealso marker="#get_handler_config/1">
- <c>logger:get_handler_config/1</c></seealso>
- and <seealso marker="#get_logger_config/0">
- <c>logger:get_logger_config/0</c></seealso>.</p>
- <p>The same as calling <c>logger:i()</c>.</p>
- </item>
- <tag><c><anno>Action</anno> = print</c></tag>
- <item>
- <p>Pretty print all the current Logger configuration to
- standard out. Example:</p>
- <code><![CDATA[1> logger:i(print).
-Current logger configuration:
- Level: info
- Filter Default: log
- Filters:
- Handlers:
- Id: default
- Module: logger_std_h
- Level: info
- Formatter:
- Module: logger_formatter
- Config: #{legacy_header => true,single_line => false,
- template => [{logger_formatter,header},"\n",msg,"\n"]}
- Filter Default: stop
- Filters:
- Id: stop_progress
- Fun: fun logger_filters:progress/2
- Config: stop
- Id: remote_gl
- Fun: fun logger_filters:remote_gl/2
- Config: stop
- Id: domain
- Fun: fun logger_filters:domain/2
- Config: {log,super,[beam,erlang,otp,sasl]}
- Id: no_domain
- Fun: fun logger_filters:domain/2
- Config: {log,undefined,[]}
- Handler Config:
- logger_std_h: #{type => standard_io}
- Level set per module:
- Module: my_module
- Level: debug]]></code>
- </item>
- </taglist>
- </desc>
- </func>
-
- <func>
- <name name="add_logger_filter" arity="2"/>
- <fsummary>Add a filter to the logger part of Logger.</fsummary>
+ <name name="add_handler" arity="3"/>
+ <fsummary>Add a handler with the given configuration.</fsummary>
<desc>
- <p>Add a filter to the logger part of Logger.</p>
- <p>The filter fun is called with the log event as the first
- parameter, and the specified <c>filter_args()</c> as the
- second parameter.</p>
- <p>The return value of the fun specifies if a log event is to
- be discarded or forwarded to the handlers:</p>
- <taglist>
- <tag><c>log_event()</c></tag>
- <item>
- <p>The filter <em>passed</em>. The next logger filter, if
- any, is applied. If no more logger filters exist, the
- log event is forwarded to the handler part of Logger,
- where handler filters are applied.</p>
- </item>
- <tag><c>stop</c></tag>
- <item>
- <p>The filter <em>did not pass</em>, and the log event is
- immediately discarded.</p>
- </item>
- <tag><c>ignore</c></tag>
- <item>
- <p>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 <c>filter_default</c>
- configuration parameter for the logger part specifies if
- the log event shall be discarded or forwarded to the
- handler part.</p>
- </item>
- </taglist>
- <p>See section <seealso marker="logger_chapter#filters">
- Filters</seealso> in the User's Guide for more information
- about filters.</p>
- <p>Some built-in filters exist. These are defined
- in <seealso marker="logger_filters"><c>logger_filters</c></seealso>.</p>
+ <p>Add a handler with the given configuration.</p>
+ <p><c><anno>HandlerId</anno></c> is a unique identifier which
+ must be used in all subsequent calls referring to this
+ handler.</p>
</desc>
</func>
@@ -541,98 +462,12 @@ Current logger configuration:
</func>
<func>
- <name name="remove_logger_filter" arity="1"/>
- <fsummary>Remove a filter from the logger part of Logger.</fsummary>
- <desc>
- <p>Remove the filter identified
- by <c><anno>FilterId</anno></c> from the logger part of Logger.</p>
- </desc>
- </func>
-
- <func>
- <name name="remove_handler_filter" arity="2"/>
- <fsummary>Remove a filter from the specified handler.</fsummary>
- <desc>
- <p>Remove the filter identified
- by <c><anno>FilterId</anno></c> from the handler identified
- by <c><anno>HandlerId</anno></c>.</p>
- </desc>
- </func>
-
- <func>
- <name name="add_handler" arity="3"/>
- <fsummary>Add a handler with the given configuration.</fsummary>
- <desc>
- <p>Add a handler with the given configuration.</p>
- <p><c><anno>HandlerId</anno></c> is a unique identifier which
- must be used in all subsequent calls referring to this
- handler.</p>
- </desc>
- </func>
-
- <func>
- <name name="remove_handler" arity="1"/>
- <fsummary>Remove the handler with the specified identity.</fsummary>
- <desc>
- <p>Remove the handler identified by <c><anno>HandlerId</anno></c>.</p>
- </desc>
- </func>
-
- <func>
- <name name="set_module_level" arity="2"/>
- <fsummary>Set the log level for the specified module.</fsummary>
- <desc>
- <p>Set the log level for the
- specified <c><anno>Module</anno></c>.</p>
- <p>The log level for a module overrides the global log level
- of Logger for log events originating from the module in
- question. Notice, however, that it does not override the
- level configuration for any handler.</p>
- <p>For example: Assume that the global log level for Logger
- is <c>info</c>, and there is one handler, <c>h1</c>, with
- level <c>info</c> and one handler, <c>h2</c>, with
- level <c>debug</c>.</p>
- <p>With this configuration, no debug messages will be logged,
- since they are all stopped by the global log level.</p>
- <p>If the level for <c>mymodule</c> is now set
- to <c>debug</c>, then debug events from this module will be
- logged by the handler <c>h2</c>, but not by
- handler <c>h1</c>.</p>
- <p>Debug events from other modules are still not logged.</p>
- <p>To change the global log level for Logger, use
- <seealso marker="#set_logger_config/2">
- <c>logger:set_logger_config(level,Level)</c></seealso>.</p>
- <p>To change the log level for a handler, use
- <seealso marker="#set_handler_config/3">
- <c>logger:set_handler_config(HandlerId,level,Level)</c></seealso>.</p>
- <note>
- <p>The originating module for a log event is only detected
- if <c>mfa=>{Module,Function,Arity}</c> exists in the
- metadata. When log macros are used, this association is
- 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 if module
- levels shall have any effect.</p>
- </note>
- </desc>
- </func>
-
- <func>
- <name name="unset_module_level" arity="1"/>
- <fsummary>Remove a module specific log setting.</fsummary>
- <desc>
- <p>Remove a module specific log setting. After this, the
- global log level is used for the specified module.</p>
- </desc>
- </func>
-
- <func>
<name name="add_handlers" arity="1" clause_i="1"/>
<fsummary>Set up log handlers from the application's
configuration parameters.</fsummary>
<desc>
<p>Reads the application configuration parameter <c>logger</c> and
- calls <c>logger:add_handlers/1</c> with its contents.</p>
+ calls <c>add_handlers/1</c> with its contents.</p>
</desc>
</func>
@@ -670,61 +505,158 @@ start(_, []) ->
[{kernel,
[{logger,
%% Disable the default Kernel handler
- [{handler,default,undefined}]}]},
+ [{handler, default, undefined}]}]},
{my_app,
[{logger,
%% Enable this handler as the default
- [{handler,default,my_handler,#{}}]}]}].
+ [{handler, default, my_handler, #{}}]}]}].
</code>
</desc>
</func>
<func>
- <name name="set_logger_config" arity="1"/>
- <fsummary>Set configuration data for the logger part of Logger.</fsummary>
+ <name name="add_primary_filter" arity="2"/>
+ <fsummary>Add a primary filter to Logger.</fsummary>
<desc>
- <p>Set configuration data for the logger part of Logger. This
- overwrites the current logger configuration.</p>
- <p>To modify the existing configuration,
- use <seealso marker="#update_logger_config-1">
- <c>update_logger_config/1</c></seealso>, or, if a more
- complex merge is needed, read the current configuration
- with <seealso marker="#get_logger_config-0"><c>get_logger_config/0</c>
- </seealso>, then do the merge before writing the new
- configuration back with this function.</p>
- <p>If a key is removed compared to the current configuration,
- the default value is used.</p>
+ <p>Add a primary filter to Logger.</p>
+ <p>The filter fun is called with the log event as the first
+ parameter, and the specified <c>filter_args()</c> as the
+ second parameter.</p>
+ <p>The return value of the fun specifies if a log event is to
+ be discarded or forwarded to the handlers:</p>
+ <taglist>
+ <tag><c>log_event()</c></tag>
+ <item>
+ <p>The filter <em>passed</em>. The next primary filter, if
+ any, is applied. If no more primary filters exist, the
+ log event is forwarded to the handler part of Logger,
+ where handler filters are applied.</p>
+ </item>
+ <tag><c>stop</c></tag>
+ <item>
+ <p>The filter <em>did not pass</em>, and the log event is
+ immediately discarded.</p>
+ </item>
+ <tag><c>ignore</c></tag>
+ <item>
+ <p>The filter has no knowledge of the log event. The next
+ primary filter, if any, is applied. If no more primary
+ filters exist, the value of the
+ primary <c>filter_default</c> configuration parameter
+ specifies if the log event shall be discarded or
+ forwarded to the handler part.</p>
+ </item>
+ </taglist>
+ <p>See section <seealso marker="logger_chapter#filters">
+ Filters</seealso> in the User's Guide for more information
+ about filters.</p>
+ <p>Some built-in filters exist. These are defined
+ in <seealso marker="logger_filters"><c>logger_filters</c></seealso>.</p>
</desc>
</func>
<func>
- <name name="set_logger_config" arity="2"/>
- <fsummary>Add or update configuration data for the logger part
- of Logger.</fsummary>
+ <name name="get_config" arity="0"/>
+ <fsummary>Look up the current Logger configuration</fsummary>
<desc>
- <p>Add or update configuration data for the logger part of
- Logger. If the given <c><anno>Key</anno></c> already exists,
- its associated value will be changed
- to <c><anno>Value</anno></c>. If it does not exist, it will
- be added.</p>
+ <p>Look up all current Logger configuration, including primary
+ and handler configuration, and module level settings.</p>
</desc>
</func>
<func>
- <name name="update_logger_config" arity="1"/>
- <fsummary>Update configuration data for the logger part of
- Logger.</fsummary>
+ <name name="get_handler_config" arity="0"/>
+ <fsummary>Look up the current configuration for all handlers.</fsummary>
<desc>
- <p>Update configuration data for the logger part of
- Logger. This function behaves as if it was implemented as
- follows:</p>
- <code type="erl">
-{ok,Old} = logger:get_logger_config(),
-logger:set_logger_config(maps:merge(Old,Config)).
- </code>
- <p>To overwrite the existing configuration without any merge,
- use <seealso marker="#set_logger_config-1"><c>set_logger_config/1</c>
- </seealso>.</p>
+ <p>Look up the current configuration for all handlers.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="get_handler_config" arity="1"/>
+ <fsummary>Look up the current configuration for the given
+ handler.</fsummary>
+ <desc>
+ <p>Look up the current configuration for the given handler.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="get_handler_ids" arity="0"/>
+ <fsummary>Look up the identities for all installed handlers.</fsummary>
+ <desc>
+ <p>Look up the identities for all installed handlers.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="get_primary_config" arity="0"/>
+ <fsummary>Look up the current primary configuration for Logger.</fsummary>
+ <desc>
+ <p>Look up the current primary configuration for Logger.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="get_module_level" arity="0"/>
+ <fsummary>Look up all current module levels.</fsummary>
+ <desc>
+ <p>Look up all current module levels. Returns a list
+ containing one <c>{Module,Level}</c> element for each module
+ for which the module level was previously set
+ with <seealso marker="#set_module_level-2">
+ <c>set_module_level/2</c></seealso>.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="get_module_level" arity="1"/>
+ <fsummary>Look up the current level for the given modules.</fsummary>
+ <desc>
+ <p>Look up the current level for the given modules. Returns a
+ list containing one <c>{Module,Level}</c> element for each
+ of the given modules for which the module level was
+ previously set with <seealso marker="#set_module_level-2">
+ <c>set_module_level/2</c></seealso>.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="get_process_metadata" arity="0"/>
+ <fsummary>Retrieve data set with set_process_metadata/1.</fsummary>
+ <desc>
+ <p>Retrieve data set
+ with <seealso marker="#set_process_metadata-1">
+ <c>set_process_metadata/1</c></seealso> or
+ <seealso marker="#update_process_metadata-1">
+ <c>update_process_metadata/1</c></seealso>.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="remove_handler" arity="1"/>
+ <fsummary>Remove the handler with the specified identity.</fsummary>
+ <desc>
+ <p>Remove the handler identified by <c><anno>HandlerId</anno></c>.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="remove_handler_filter" arity="2"/>
+ <fsummary>Remove a filter from the specified handler.</fsummary>
+ <desc>
+ <p>Remove the filter identified
+ by <c><anno>FilterId</anno></c> from the handler identified
+ by <c><anno>HandlerId</anno></c>.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="remove_primary_filter" arity="1"/>
+ <fsummary>Remove a primary filter from Logger.</fsummary>
+ <desc>
+ <p>Remove the primary filter identified
+ by <c><anno>FilterId</anno></c> from Logger.</p>
</desc>
</func>
@@ -763,18 +695,122 @@ logger:set_logger_config(maps:merge(Old,Config)).
</func>
<func>
- <name name="update_handler_config" arity="2"/>
- <fsummary>Update configuration data for the specified handler.</fsummary>
+ <name name="set_primary_config" arity="1"/>
+ <fsummary>Set primary configuration data for Logger.</fsummary>
<desc>
- <p>Update configuration data for the specified handler. This function
- behaves as if it was implemented as follows:</p>
- <code type="erl">
-{ok,{_,Old}} = logger:get_handler_config(HandlerId),
-logger:set_handler_config(HandlerId,maps:merge(Old,Config)).
- </code>
- <p>To overwrite the existing configuration without any merge,
- use <seealso marker="#set_handler_config-2"><c>set_handler_config/2</c>
+ <p>Set primary configuration data for Logger. This
+ overwrites the current configuration.</p>
+ <p>To modify the existing configuration,
+ use <seealso marker="#update_primary_config-1">
+ <c>update_primary_config/1</c></seealso>, or, if a more
+ complex merge is needed, read the current configuration
+ with <seealso marker="#get_primary_config-0"><c>get_primary_config/0</c>
+ </seealso>, then do the merge before writing the new
+ configuration back with this function.</p>
+ <p>If a key is removed compared to the current configuration,
+ the default value is used.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="set_primary_config" arity="2"/>
+ <fsummary>Add or update primary configuration data for Logger.</fsummary>
+ <desc>
+ <p>Add or update primary configuration data for Logger. If the
+ given <c><anno>Key</anno></c> already exists, its associated
+ value will be changed to <c><anno>Value</anno></c>. If it
+ does not exist, it will be added.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="set_module_level" arity="2"/>
+ <fsummary>Set the log level for the specified modules.</fsummary>
+ <desc>
+ <p>Set the log level for the
+ specified modules.</p>
+ <p>The log level for a module overrides the primary log level
+ of Logger for log events originating from the module in
+ question. Notice, however, that it does not override the
+ level configuration for any handler.</p>
+ <p>For example: Assume that the primary log level for Logger
+ is <c>info</c>, and there is one handler, <c>h1</c>, with
+ level <c>info</c> and one handler, <c>h2</c>, with
+ level <c>debug</c>.</p>
+ <p>With this configuration, no debug messages will be logged,
+ since they are all stopped by the primary log level.</p>
+ <p>If the level for <c>mymodule</c> is now set
+ to <c>debug</c>, then debug events from this module will be
+ logged by the handler <c>h2</c>, but not by
+ handler <c>h1</c>.</p>
+ <p>Debug events from other modules are still not logged.</p>
+ <p>To change the primary log level for Logger, use
+ <seealso marker="#set_primary_config/2">
+ <c>set_primary_config(level, Level)</c></seealso>.</p>
+ <p>To change the log level for a handler, use
+ <seealso marker="#set_handler_config/3">
+ <c>set_handler_config(HandlerId, level, Level)</c>
</seealso>.</p>
+ <note>
+ <p>The originating module for a log event is only detected
+ if the key <c>mfa</c> exists in the metadata, and is
+ associated with <c>{Module, Function, Arity}</c>. When log
+ macros are used, this association is 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 if module levels shall have any
+ effect.</p>
+ </note>
+ </desc>
+ </func>
+
+ <func>
+ <name name="set_process_metadata" arity="1"/>
+ <fsummary>Set metadata to use when logging from current process.</fsummary>
+ <desc>
+ <p>Set metadata which Logger shall automatically insert in
+ all log events produced on the current process.</p>
+ <p>Location data produced by the log macros, and/or metadata
+ given as argument to the log call (API function or macro),
+ are merged with the process metadata. If the same keys
+ occur, values from the metadata argument to the log call
+ overwrite values from the process metadata, which in turn
+ overwrite values from the location data.</p>
+ <p>Subsequent calls to this function overwrites previous data
+ set. To update existing data instead of overwriting it,
+ see <seealso marker="#update_process_metadata-1">
+ <c>update_process_metadata/1</c></seealso>.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="unset_module_level" arity="0"/>
+ <fsummary>Remove module specific log settings for all modules.</fsummary>
+ <desc>
+ <p>Remove module specific log settings. After this, the
+ primary log level is used for all modules.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="unset_module_level" arity="1"/>
+ <fsummary>Remove module specific log settings for the given
+ modules.</fsummary>
+ <desc>
+ <p>Remove module specific log settings. After this, the
+ primary log level is used for the specified modules.</p>
+ </desc>
+ </func>
+
+ <func>
+ <name name="unset_process_metadata" arity="0"/>
+ <fsummary>Delete data set with set_process_metadata/1.</fsummary>
+ <desc>
+ <p>Delete data set
+ with <seealso marker="#set_process_metadata-1">
+ <c>set_process_metadata/1</c></seealso> or
+ <seealso marker="#update_process_metadata-1">
+ <c>update_process_metadata/1</c></seealso>.</p>
</desc>
</func>
@@ -786,9 +822,10 @@ logger:set_handler_config(HandlerId,maps:merge(Old,Config)).
<p>The new configuration is merged with the existing formatter
configuration.</p>
<p>To overwrite the existing configuration without any merge,
- use <seealso marker="#set_handler_config-3">
- <c>set_handler_config(HandlerId,formatter,
- {FormatterModule,FormatterConfig})</c></seealso>.</p>
+ use</p>
+ <pre>
+<seealso marker="#set_handler_config-3">set_handler_config(HandlerId, formatter,
+ {FormatterModule, FormatterConfig})</seealso>.</pre>
</desc>
</func>
@@ -797,39 +834,41 @@ logger:set_handler_config(HandlerId,maps:merge(Old,Config)).
<fsummary>Update the formatter configuration for the specified handler.</fsummary>
<desc>
<p>Update the formatter configuration for the specified handler.</p>
- <p>This is equivalent
- to <br/><seealso marker="#update_formatter_config-2">
- <c>update_formatter_config(<anno>HandlerId</anno>,#{<anno>Key</anno>=><anno>Value</anno>})</c></seealso></p>
+ <p>This is equivalent to</p>
+ <pre>
+<seealso marker="#update_formatter_config-2">update_formatter_config(<anno>HandlerId</anno>, #{<anno>Key</anno> => <anno>Value</anno>})</seealso></pre>
</desc>
</func>
<func>
- <name name="compare_levels" arity="2"/>
- <fsummary>Compare the severity of two log levels.</fsummary>
+ <name name="update_handler_config" arity="2"/>
+ <fsummary>Update configuration data for the specified handler.</fsummary>
<desc>
- <p>Compare the severity of two log levels. Returns <c>gt</c>
- if <c>Level1</c> is more severe than
- <c>Level2</c>, <c>lt</c> if <c>Level1</c> is less severe,
- and <c>eq</c> if the levels are equal.</p>
+ <p>Update configuration data for the specified handler. This function
+ behaves as if it was implemented as follows:</p>
+ <code type="erl">
+{ok, {_, Old}} = logger:get_handler_config(HandlerId),
+logger:set_handler_config(HandlerId, maps:merge(Old, Config)).
+ </code>
+ <p>To overwrite the existing configuration without any merge,
+ use <seealso marker="#set_handler_config-2"><c>set_handler_config/2</c>
+ </seealso>.</p>
</desc>
</func>
<func>
- <name name="set_process_metadata" arity="1"/>
- <fsummary>Set metadata to use when logging from current process.</fsummary>
+ <name name="update_primary_config" arity="1"/>
+ <fsummary>Update primary configuration data for Logger.</fsummary>
<desc>
- <p>Set metadata which Logger shall automatically insert in
- all log events produced on the current process.</p>
- <p>Location data produced by the log macros, and/or metadata
- given as argument to the log call (API function or macro),
- are merged with the process metadata. If the same keys
- occur, values from the metadata argument to the log call
- overwrite values from the process metadata, which in turn
- overwrite values from the location data.</p>
- <p>Subsequent calls to this function overwrites previous data
- set. To update existing data instead of overwriting it,
- see <seealso marker="#update_process_metadata-1">
- <c>update_process_metadata/1</c></seealso>.</p>
+ <p>Update primary configuration data for Logger. This function
+ behaves as if it was implemented as follows:</p>
+ <code type="erl">
+Old = logger:get_primary_config(),
+logger:set_primary_config(maps:merge(Old, Config)).
+ </code>
+ <p>To overwrite the existing configuration without any merge,
+ use <seealso marker="#set_primary_config-1"><c>set_primary_config/1</c>
+ </seealso>.</p>
</desc>
</func>
@@ -843,7 +882,7 @@ logger:set_handler_config(HandlerId,maps:merge(Old,Config)).
<p>If process metadata exists for the current process, this
function behaves as if it was implemented as follows:</p>
<code type="erl">
-logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
+logger:set_process_metadata(maps:merge(logger:get_process_metadata(), Meta)).
</code>
<p>If no process metadata exists, the function behaves as
<seealso marker="#set_process_metadata-1">
@@ -851,48 +890,44 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
</seealso>.</p>
</desc>
</func>
+ </funcs>
+ <section>
+ <marker id="misc_API"/>
+ <title>Miscellaneous API functions</title>
+ </section>
+ <funcs>
<func>
- <name name="get_process_metadata" arity="0"/>
- <fsummary>Retrieve data set with set_process_metadata/1.</fsummary>
- <desc>
- <p>Retrieve data set
- with <seealso marker="#set_process_metadata-1">
- <c>set_process_metadata/1</c></seealso> or
- <seealso marker="#update_process_metadata-1">
- <c>update_process_metadata/1</c></seealso>.</p>
- </desc>
- </func>
-
- <func>
- <name name="unset_process_metadata" arity="0"/>
- <fsummary>Delete data set with set_process_metadata/1.</fsummary>
+ <name name="compare_levels" arity="2"/>
+ <fsummary>Compare the severity of two log levels.</fsummary>
<desc>
- <p>Delete data set
- with <seealso marker="#set_process_metadata-1">
- <c>set_process_metadata/1</c></seealso> or
- <seealso marker="#update_process_metadata-1">
- <c>update_process_metadata/1</c></seealso>.</p>
+ <p>Compare the severity of two log levels. Returns <c>gt</c>
+ if <c>Level1</c> is more severe than
+ <c>Level2</c>, <c>lt</c> if <c>Level1</c> is less severe,
+ and <c>eq</c> if the levels are equal.</p>
</desc>
</func>
<func>
<name name="format_report" arity="1"/>
- <fsummary>Convert a log message on report form to {Format,Args}.</fsummary>
+ <fsummary>Convert a log message on report form to {Format, Args}.</fsummary>
<desc>
- <p>Convert a log message on report form to <c>{Format,Args}</c>.</p>
- <p>This is the default report callback used
+ <p>Convert a log message on report form to <c>{Format,
+ Args}</c>. This is the default report callback used
by <seealso marker="logger_formatter">
<c>logger_formatter</c></seealso> when no custom report
- callback is found.</p>
+ callback is found. See
+ section <seealso marker="logger_chapter#log_message">Log
+ Message</seealso> in the Kernel User's Guide for
+ information about report callbacks and valid forms of log
+ messages.</p>
<p>The function produces lines of <c>Key: Value</c> from
key-value lists. Strings are printed with <c>~ts</c> and
other terms with <c>~tp</c>.</p>
- <p>If the <c><anno>Report</anno></c> is a map, it is
- converted to a key-value list before formatting as such.</p>
+ <p>If <c><anno>Report</anno></c> is a map, it is converted to
+ a key-value list before formatting as such.</p>
</desc>
</func>
-
</funcs>
<section>
@@ -904,11 +939,11 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
<funcs>
<func>
- <name>HModule:adding_handler(Config1) -> {ok,Config2} | {error,Reason}</name>
+ <name>HModule:adding_handler(Config1) -> {ok, Config2} | {error, Reason}</name>
<fsummary>An instance of this handler is about to be added.</fsummary>
<type>
<v>Config1 = Config2 =
- <seealso marker="#type-config">config()</seealso></v>
+ <seealso marker="#type-handler_config">handler_config()</seealso></v>
<v>Reason = term()</v>
</type>
<desc>
@@ -928,11 +963,11 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
</func>
<func>
- <name>HModule:changing_config(Config1,Config2) -> {ok,Config3} | {error,Reason}</name>
+ <name>HModule:changing_config(Config1, Config2) -> {ok, Config3} | {error, Reason}</name>
<fsummary>The configuration for this handler is about to change.</fsummary>
<type>
<v>Config1 = Config2 = Config3 =
- <seealso marker="#type-config">config()</seealso></v>
+ <seealso marker="#type-handler_config">handler_config()</seealso></v>
<v>Reason = term()</v>
</type>
<desc>
@@ -952,17 +987,17 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
</func>
<func>
- <name>HModule:log(LogEvent,Config) -> void()</name>
+ <name>HModule:log(LogEvent, Config) -> void()</name>
<fsummary>Log the given log event.</fsummary>
<type>
<v>LogEvent =
<seealso marker="#type-log_event">log_event()</seealso></v>
<v>Config =
- <seealso marker="#type-config">config()</seealso></v>
+ <seealso marker="#type-handler_config">handler_config()</seealso></v>
</type>
<desc>
<p>This callback function is mandatory.</p>
- <p>The function is called when all global filters and all
+ <p>The function is called when all primary filters and all
handler filters for the handler in question have passed for
the given log event.</p>
<p>The handler identity is associated with the <c>id</c> key
@@ -978,7 +1013,7 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
<fsummary>The given handler is about to be removed.</fsummary>
<type>
<v>Config =
- <seealso marker="#type-config">config()</seealso></v>
+ <seealso marker="#type-handler_config">handler_config()</seealso></v>
</type>
<desc>
<p>This callback function is optional.</p>
@@ -1002,18 +1037,30 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
<funcs>
<func>
- <name>FModule:check_config(FConfig) -> ok | {error,term()}</name>
+ <name>FModule:check_config(FConfig) -> ok | {error, Reason}</name>
<fsummary>Validate the given formatter configuration.</fsummary>
<type>
<v>FConfig =
<seealso marker="#type-formatter_config">formatter_config()</seealso></v>
+ <v>Reason = term()</v>
</type>
<desc>
<p>This callback function is optional.</p>
<p>The function is called by a Logger when formatter
configuration is set or modified. The formatter must
validate the given configuration and return <c>ok</c> if it
- is correct, and <c>{error,term()}</c> if it is faulty.</p>
+ is correct, and <c>{error,Reason}</c> if it is faulty.</p>
+ <p>The following Logger API functions can trigger this callback:</p>
+ <list>
+ <item><seealso marker="logger#add_handler-3">
+ <c>logger:add_handler/3</c></seealso></item>
+ <item><seealso marker="logger#set_handler_config-2">
+ <c>logger:set_handler_config/2,3</c></seealso></item>
+ <item><seealso marker="logger#update_handler_config-2">
+ <c>logger:updata_handler_config/2</c></seealso></item>
+ <item><seealso marker="logger#update_formatter_config-2">
+ <c>logger:update_formatter_config/2</c></seealso></item>
+ </list>
<p>See <seealso marker="logger_formatter">
<c>logger_formatter(3)</c></seealso>
for an example implementation. <c>logger_formatter</c> is the
@@ -1021,7 +1068,7 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
</desc>
</func>
<func>
- <name>FModule:format(LogEvent,FConfig) -> FormattedLogEntry</name>
+ <name>FModule:format(LogEvent, FConfig) -> FormattedLogEntry</name>
<fsummary>Format the given log event.</fsummary>
<type>
<v>LogEvent =
@@ -1045,6 +1092,20 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(),Meta)).
</desc>
</func>
</funcs>
+
+ <section>
+ <title>See Also</title>
+ <p>
+ <seealso marker="config"><c>config(4)</c></seealso>,
+ <seealso marker="erts:erlang"><c>erlang(3)</c></seealso>,
+ <seealso marker="stdlib:io"><c>io(3)</c></seealso>,
+ <seealso marker="logger_disk_log_h"><c>logger_disk_log_h(3)</c></seealso>,
+ <seealso marker="logger_filters"><c>logger_filters(3)</c></seealso>,
+ <seealso marker="logger_formatter"><c>logger_formatter(3)</c></seealso>,
+ <seealso marker="logger_std_h"><c>logger_std_h(3)</c></seealso>,
+ <seealso marker="stdlib:unicode"><c>unicode(3)</c></seealso>
+ </p>
+ </section>
</erlref>
diff --git a/lib/kernel/doc/src/logger_arch.png b/lib/kernel/doc/src/logger_arch.png
index 901122193a..a9b9a658b4 100644
--- a/lib/kernel/doc/src/logger_arch.png
+++ b/lib/kernel/doc/src/logger_arch.png
Binary files differ
diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml
index a3eec7bd4b..f7df0a3e6e 100644
--- a/lib/kernel/doc/src/logger_chapter.xml
+++ b/lib/kernel/doc/src/logger_chapter.xml
@@ -30,7 +30,7 @@
<file>logger_chapter.xml</file>
</header>
- <p>Erlang/OTP 21.0 provides a new standard API for logging
+ <p>Erlang/OTP 21.0 provides a standard API for logging
through <c>Logger</c>, 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
@@ -44,7 +44,7 @@
<p>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 <seealso marker="disk_log"><c>disk_log</c></seealso>.</p>
- <p>By confiugration, you can aslo modify or disable the default
+ <p>By configuration, you can also modify or disable the default
handler, replace it by a custom handler, and install additional
handlers.</p>
@@ -53,11 +53,12 @@
<p>A <em>log event</em> consists of a <em>log level</em>, the
<em>message</em> to be logged, and <em>metadata</em>.</p>
<p>The Logger backend forwards log events from the API, first
- through a set of <em>global filters</em>, then through a set
- of <em>handler filters</em> for each log handler.</p>
+ through a set of <em>primary filters</em>, then through a set of
+ secondary filters attached to each log handler. The secondary
+ filters are in the following named <em>handler filters</em>.</p>
<p>Each filter set consists of a <em>log level check</em>,
followed by zero or more <em>filter functions</em>.</p>
- <p>The following figure show a conseptual overview of Logger. The
+ <p>The following figure shows a conceptual overview of Logger. The
figure shows two log handlers, but any number of handlers can be
installed.</p>
@@ -69,11 +70,11 @@
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
+ the check passes if the event is equally or more severe than the
configured level. See section <seealso marker="#log_level">Log
Level</seealso> for a listing and description of all log
levels.</p>
- <p>The global log level can be overridden by a log level
+ <p>The primary 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.</p>
<p>Filter functions can be used for more sophisticated filtering
@@ -82,7 +83,7 @@
also modify all parts of the log event. See see
section <seealso marker="#filters">Filters</seealso> for more
details.</p>
- <p>If a log event passes through all global filters and all
+ <p>If a log event passes through all primary 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
@@ -107,7 +108,7 @@
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.</p>
+ log level of the event passes the primary log level check.</p>
<section>
<marker id="log_level"/>
<title>Log Level</title>
@@ -136,7 +137,7 @@
<row>
<cell>critical</cell>
<cell align="center">2</cell>
- <cell>critical contidions</cell>
+ <cell>critical conditions</cell>
</row>
<row>
<cell>error</cell>
@@ -178,9 +179,9 @@
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 <seealso marker="#metadata">metadata</seealso>. The
- report callback is a convenience function that
+ can be accompanied by a <em>report callback</em> specified in
+ the log event's <seealso marker="#metadata">metadata</seealso>.
+ The report callback is a convenience function that
the <seealso marker="#formatters">formatter</seealso> can use
to convert the report to a format string and arguments. The
formatter can also use its own conversion function, if no
@@ -195,7 +196,7 @@
logger:debug(#{got => connection_request, id => Id, state => State},
#{report_cb => fun(R) -> {"~p",[R]} end})</code>
<p>The log message can also be provided through a fun for lazy
- evaluation. The fun is only evaluated if the global log level
+ evaluation. The fun is only evaluated if the primary 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.</p>
@@ -217,9 +218,9 @@ logger:debug(#{got => connection_request, id => Id, state => State},
which these calls are made, and Logger adds the metadata
to all log events issued on that process.</p>
</item>
- <tag>Add metadata to a specifc log event</tag>
+ <tag>Add metadata to a specific log event</tag>
<item>
- <p>Metadata associated with one specifc log event is given
+ <p>Metadata associated with one specific log event is given
as the last parameter to the log macro or Logger API
function when the event is issued. For example:</p>
<code>?LOG_ERROR("Connection closed",#{context => server})</code>
@@ -235,8 +236,8 @@ logger:debug(#{got => connection_request, id => Id, state => State},
<section>
<marker id="filter"/>
<title>Filters</title>
- <p>Filters can be global, or attached to a specific
- handler. Logger calls the global filters first, and if they all
+ <p>Filters can be primary, or attached to a specific
+ handler. Logger calls the primary 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.</p>
@@ -251,7 +252,7 @@ logger:debug(#{got => connection_request, id => Id, state => State},
<p>The filter function can return <c>stop</c>, <c>ignore</c> or
the (possibly modified) log event.</p>
<p>If <c>stop</c> is returned, the log event is immediately
- discarded. If the filter is global, no handler filters or
+ discarded. If the filter is primary, 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 filters attached to the next handler, if
@@ -265,23 +266,21 @@ logger:debug(#{got => connection_request, id => Id, state => State},
<p>If the filter function returns <c>ignore</c>, it means that it
did not recognize the log event, and thus leaves to other
filters to decide the event's destiny.</p>
- <p>The configuration
- option <seealso marker="#filter_default"><c>filter_default</c></seealso>
- specifies the behaviour if all filter functions
- return <c>ignore</c>, or if no filters
- exist. <c>filter_default</c> is by default set to <c>log</c>,
- meaning that if all existing filters ignore a log event, Logger
- forwards the event to the handler
+ <p>The configuration option <c>filter_default</c> specifies the
+ behaviour if all filter functions return <c>ignore</c>, or if no
+ filters exist. <c>filter_default</c> is by default set
+ to <c>log</c>, meaning that if all existing filters ignore a log
+ event, Logger forwards the event to the handler
callback. If <c>filter_default</c> is set to <c>stop</c>, Logger
discards such events.</p>
- <p>Global filters are added
- with <seealso marker="logger#add_logger_filter-2">
- <c>logger:add_logger_filter/2</c></seealso>
+ <p>Primary filters are added
+ with <seealso marker="logger#add_primary_filter-2">
+ <c>logger:add_primary_filter/2</c></seealso>
and removed
- with <seealso marker="logger#remove_logger_filter-1">
- <c>logger:remove_logger_filter/1</c></seealso>. They can also
+ with <seealso marker="logger#remove_primary_filter-1">
+ <c>logger:remove_primary_filter/1</c></seealso>. They can also
be added at system start via the Kernel configuration
- parameter <seealso marker="#logger"><c>logger</c></seealso>.</p>
+ parameter <seealso marker="#logger_parameter"><c>logger</c></seealso>.</p>
<p>Handler filters are added
with <seealso marker="logger#add_handler_filter-3">
<c>logger:add_handler_filter/3</c></seealso>
@@ -292,12 +291,13 @@ logger:debug(#{got => connection_request, id => Id, state => State},
with <seealso marker="logger#add_handler/3">
<c>logger:add_handler/3</c></seealso>
or via the Kernel configuration
- parameter <seealso marker="#logger"><c>logger</c></seealso>.</p>
+ parameter <seealso marker="#logger_parameter"><c>logger</c></seealso>.</p>
<p>To see which filters are currently installed in the system,
- use <seealso marker="logger#i-0"><c>logger:i/0</c></seealso>,
- or <seealso marker="logger#get_logger_config-0">
- <c>logger:get_logger_config/0</c></seealso>
+ use <seealso marker="logger#get_config-0">
+ <c>logger:get_config/0</c></seealso>,
+ or <seealso marker="logger#get_primary_config-0">
+ <c>logger:get_primary_config/0</c></seealso>
and <seealso marker="logger#get_handler_config-1">
<c>logger:get_handler_config/1</c></seealso>. Filters are
listed in the order they are applied, that is, the first
@@ -342,7 +342,7 @@ logger:debug(#{got => connection_request, id => Id, state => State},
<pre><seealso marker="logger#HModule:log-2">log(LogEvent, Config) -> void()</seealso></pre>
<p>This function is called when a log event has passed through all
- global filters, and all handler filters attached to the handler
+ primary 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 involved or not.</p>
@@ -358,8 +358,8 @@ logger:debug(#{got => connection_request, id => Id, state => State},
functions <c>adding_handler/1</c>, <c>changing_config/2</c>
and <c>removing_handler/1</c>. See
section <seealso marker="logger#handler_callback_functions">Handler
- Callback Functions</seealso> in the logger(3) manual for more
- information about these function.</p>
+ Callback Functions</seealso> in the logger(3) manual page for
+ more information about these function.</p>
<p>The following built-in handlers exist:</p>
@@ -404,7 +404,7 @@ logger:debug(#{got => connection_request, id => Id, state => State},
which is passed as the second argument
to <seealso marker="logger#HModule:log-2">
<c>HModule:log/2</c></seealso>.</p>
- <p>The formatter information consits of a formatter
+ <p>The formatter information consist of a formatter
module, <c>FModule</c> and its
configuration, <c>FConfig</c>. <c>FModule</c> must export the
following function, which can be called by the handler:</p>
@@ -425,152 +425,92 @@ logger:debug(#{got => connection_request, id => Id, state => State},
function when the formatter information is set or modified, to
verify the validity of the formatter configuration.</p>
<p>If no formatter information is specified for a handler, Logger
- uses <seealso marker="logger_formatter">
- <c>logger_formatter(3)</c></seealso> as default.</p>
+ uses <c>logger_formatter</c> as default. See
+ the <seealso marker="logger_formatter"><c>logger_formatter(3)</c></seealso>
+ manual page for more information about this module.</p>
</section>
<section>
<title>Configuration</title>
- <p>Logger can be configured either when the system starts through
- <seealso marker="config">configuration parameters</seealso>,
- or at run-time by using the <seealso marker="logger">logger(3)</seealso>
- API. The recommended approach is to do the initial configuration in
- the <c>sys.config</c> file and then use the API when some configuration
- has to be changed at runtime, such as the log level.</p>
+ <p>At system start, Logger is configured through Kernel
+ configuration parameters. The parameters that apply to Logger
+ are described in
+ section <seealso marker="#kernel_config_params">Kernel
+ Configuration Parameters</seealso>. Examples are found in
+ section <seealso marker="#config_examples">Configuration
+ Examples</seealso>.</p>
+ <p>During runtime, Logger configuration is changed via API
+ functions. See
+ section <seealso marker="logger#configuration_API">Configuration
+ API Functions</seealso> in the <c>logger(3)</c> manual page.</p>
<section>
- <title>Kernel Configuration Parameters</title>
- <p>Logger is best configured by using the configuration parameters
- of Kernel. There are four possible configuration parameters:
- <seealso marker="#logger"><c>logger</c></seealso>,
- <seealso marker="kernel_app#logger_level"><c>logger_level</c></seealso>,
- <seealso marker="kernel_app#logger_sasl_compatible"><c>logger_sasl_compatible</c></seealso> and
- <seealso marker="kernel_app#logger_progress_reports"><c>logger_progress_reports</c></seealso>.
- <c>logger_level</c>, <c>logger_sasl_compatible</c> and <c>logger_progress_reports</c> are described in the
- <seealso marker="kernel_app#configuration">Kernel Configuration</seealso>,
- while <c>logger</c> is described below.</p>
-
- <marker id="logger"/>
- <p><em>logger</em></p>
- <p>The application configuration parameter <c>logger</c> 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:</p>
- <taglist>
- <tag><c>DisableHandler = {handler,default,undefined}</c></tag>
- <item>
- <p>Disable the default handler. This allows another application
- to add its own default handler. See <seealso marker="logger#add_handlers/1">
- <c>logger:add_handlers/1</c></seealso> for more details.</p>
- <p>Only one entry of this option is allowed.</p></item>
- <tag><c>AddHandler = {handler,HandlerId,Module,HandlerConfig}</c></tag>
- <item>
- <p>Add a handler as if <seealso marker="logger:add_handler/3">
- <c>logger:add_handler(HandlerId,Module,HandlerConfig)</c></seealso> is
- called.</p>
- <p>It is allowed to have multiple entries of this option.</p></item>
- <tag><c>Filters = {filters, default, [Filter]}</c><br/>
- <c>FilterDefault = log | stop</c><br/>
- <c>Filter = {FilterId, {FilterFun, FilterConfig}}</c></tag>
- <item>
- <p>Add the specified <seealso marker="logger#add_logger_filter/2">
- logger filters</seealso>.</p>
- <p>Only one entry of this option is allowed.</p></item>
- <tag><c>ModuleLevel = {module_level, Level, [Module]}</c></tag>
- <item>
- <p>This option configures <seealso marker="logger#set_module_level/2">
- module log level</seealso>.</p>
- <p>It is allowed to have multiple entries of this option.</p></item>
- </taglist>
- <p>Examples:</p>
- <list>
- <item>
- <p>Output logs into the file &quot;logs/erlang.log&quot;</p>
- <code>
-[{kernel,
- [{logger,
- [{handler, default, logger_std_h,
- #{ logger_std_h => #{ type => {file,"log/erlang.log"}}}}]}]}].
- </code>
- </item>
- <item>
- <p>Output logs in single line format</p>
- <code>
-[{kernel,
- [{logger,
- [{handler, default, logger_std_h,
- #{ formatter => { logger_formatter,#{ single_line => true}}}}]}]}].
- </code>
- </item>
- <item>
- <p>Add the pid to each log event</p>
- <code>
-[{kernel,
- [{logger,
- [{handler, default, logger_std_h,
- #{ formatter => { logger_formatter,
- #{ template => [time," ",pid," ",msg,"\n"]}}
- }}]}]}].
- </code>
- </item>
- <item>
- <p>Use a different file for debug logging</p>
- <code>
-[{kernel,
- [{logger,
- [{handler, default, logger_std_h,
- #{ level => error,
- logger_std_h => #{ type => {file, "log/erlang.log"}}}},
- {handler, info, logger_std_h,
- #{ level => debug,
- logger_std_h => #{ type => {file, "log/debug.log"}}}}
- ]}]}].
- </code>
- </item>
- </list>
- </section>
-
- <section>
- <title>Global Logger Configuration</title>
-
+ <title>Primary Logger Configuration</title>
+ <p>Logger API functions that apply to the primary Logger
+ configuration are:</p>
+ <list>
+ <item><seealso marker="logger#get_primary_config-0">
+ <c>get_primary_config/0</c></seealso></item>
+ <item><seealso marker="logger#set_primary_config-1">
+ <c>set_primary_config/1,2</c></seealso></item>
+ <item><seealso marker="logger#update_primary_config-1">
+ <c>update_primary_config/1</c></seealso></item>
+ <item><seealso marker="logger#add_primary_filter-2">
+ <c>add_primary_filter/2</c></seealso></item>
+ <item><seealso marker="logger#remove_primary_filter-1">
+ <c>remove_primary_filter/1</c></seealso></item>
+ </list>
+ <p>The primary Logger configuration is a map with the following
+ keys:</p>
<taglist>
- <tag><c>level = </c><seealso marker="logger#type-level">
- <c>logger:level()</c></seealso></tag>
+ <tag><marker id="primary_level"/>
+ <c>level = </c><seealso marker="logger#type-level">
+ <c>logger:level()</c></seealso><c> | all | none</c></tag>
<item>
- <p>Specifies the global log level to log.</p>
+ <p>Specifies the primary log level, that is, log event that
+ are equally or more severe than this level, are forwarded
+ to the primary filters. Less severe log events are
+ immediately discarded.</p>
<p>See section <seealso marker="#log_level">Log
Level</seealso> for a listing and description of
possible log levels.</p>
<p>The initial value of this option is set by the Kernel
- configuration
- parameter <seealso marker="kernel_app#logger_level">
- <c>logger_level</c></seealso>. It can be changed during
- runtime
- with <seealso marker="logger#set_logger_config-2">
- <c>logger:set_logger_config(level,NewLevel)</c></seealso>.</p>
+ configuration parameter <seealso marker="#logger_level">
+ <c>logger_level</c></seealso>. It is changed during
+ runtime with <seealso marker="logger#set_primary_config-2">
+ <c>logger:set_primary_config(level,Level)</c></seealso>.</p>
+ <p>Defaults to <c>info</c>.</p>
</item>
- <tag><c>filters = [{</c><seealso marker="logger#type-filter_id">
- <c>logger:filter_id()</c></seealso><c>,</c>
- <seealso marker="logger#type-filter">
- <c>logger:filter()</c></seealso><c>}]</c></tag>
+ <tag><c>filters = [{FilterId,Filter}]</c></tag>
<item>
- <p>Global filters are added and removed with
- <seealso marker="logger#add_logger_filter-2">
- <c>logger:add_logger_filter/2</c></seealso> and
- <seealso marker="logger#remove_logger_filter-1">
- <c>logger:remove_logger_filter/1</c></seealso>,
+ <p>Specifies the primary filters.</p>
+ <list>
+ <item><c>FilterId = </c><seealso marker="logger#type-filter_id">
+ <c>logger:filter_id()</c></seealso></item>
+ <item><c>Filter = </c><seealso marker="logger#type-filter">
+ <c>logger:filter()</c></seealso></item>
+ </list>
+ <p>The initial value of this option is set by the Kernel
+ configuration
+ parameter <seealso marker="#logger_parameter"><c>logger</c></seealso>.
+ During runtime, primary filters are added and removed with
+ <seealso marker="logger#add_primary_filter-2">
+ <c>logger:add_primary_filter/2</c></seealso> and
+ <seealso marker="logger#remove_primary_filter-1">
+ <c>logger:remove_primary_filter/1</c></seealso>,
respectively.</p>
<p>See section <seealso marker="#filters">Filters</seealso>
- for more information.</p>
- <p>Default is <c>[]</c>, that is, no filters exist.</p>
+ for more detailed information.</p>
+ <p>Defaults to <c>[]</c>.</p>
</item>
- <tag><marker id="filter_default"/><c>filter_default = log | stop</c></tag>
+ <tag><c>filter_default = log | stop</c></tag>
<item>
- <p>Specifies what to do with an event if all filters
+ <p>Specifies what happens to a log event if all filters
return <c>ignore</c>, or if no filters exist.</p>
<p>See section <seealso marker="#filters">Filters</seealso>
for more information about how this option is used.</p>
- <p>Default is <c>log</c>.</p>
+ <p>Defaults to <c>log</c>.</p>
</item>
</taglist>
</section>
@@ -578,26 +518,64 @@ logger:debug(#{got => connection_request, id => Id, state => State},
<section>
<marker id="handler_configuration"/>
<title>Handler Configuration</title>
+ <p>Logger API functions that apply to handler configuration
+ are:</p>
+ <list>
+ <item><seealso marker="logger#get_handler_config-0">
+ <c>get_handler_config/0,1</c></seealso></item>
+ <item><seealso marker="logger#set_handler_config-2">
+ <c>set_handler_config/2,3</c></seealso></item>
+ <item><seealso marker="logger#update_handler_config-2">
+ <c>update_handler_config/2</c></seealso></item>
+ <item><seealso marker="logger#add_handler_filter-3">
+ <c>add_handler_filter/3</c></seealso></item>
+ <item><seealso marker="logger#remove_handler_filter-2">
+ <c>remove_handler_filter/2</c></seealso></item>
+ <item><seealso marker="logger#update_formatter_config-2">
+ <c>update_formatter_config/2,3</c></seealso></item>
+ </list>
+ <p>The configuration for a handler is a map with the following keys:</p>
<taglist>
+ <tag><c>id = </c><seealso marker="logger#type-handler_id">
+ <c>logger:handler_id()</c></seealso></tag>
+ <item>
+ <p>Automatically inserted by Logger. The value is the same
+ as the <c>HandlerId</c> specified when adding the handler,
+ and it cannot be changed.</p>
+ </item>
+ <tag><c>module = module()</c></tag>
+ <item>
+ <p>Automatically inserted by Logger. The value is the same
+ as the <c>Module</c> specified when adding the handler,
+ and it cannot be changed.</p>
+ </item>
<tag><c>level = </c><seealso marker="logger#type-level">
- <c>logger:level()</c></seealso></tag>
+ <c>logger:level()</c></seealso><c> | all | none</c></tag>
<item>
- <p>Specifies the log level which the handler logs.</p>
+ <p>Specifies the log level for the handler, that is, log
+ events that are equally or more severe than this level,
+ are forwarded to the handler filters for this
+ handler.</p>
<p>See section <seealso marker="#log_level">Log
Level</seealso> for a listing and description of
possible log levels.</p>
- <p>The log level can be specified when adding the handler,
- or changed during runtime with, for
+ <p>The log level is specified when adding the handler, or
+ changed during runtime with, for
instance, <seealso marker="logger#set_handler_config/3">
- <c>logger:set_handler_config/3</c></seealso>.</p>
- <p>Default is <c>info</c>.</p>
+ <c>logger:set_handler_config(HandlerId,level,Level)</c></seealso>.
+ </p>
+ <p>Defaults to <c>all</c>.</p>
</item>
- <tag><c>filters = [{</c><seealso marker="logger#type-filter_id">
- <c>logger:filter_id()</c></seealso><c>,</c>
- <seealso marker="logger#type-filter">
- <c>logger:filter()</c></seealso><c>}]</c></tag>
+ <tag><c>filters = [{FilterId,Filter}]</c></tag>
<item>
- <p>Handler filters can be specified when adding the handler,
+ <p>Specifies the handler filters.</p>
+ <list>
+ <item><c>FilterId = </c><seealso marker="logger#type-filter_id">
+ <c>logger:filter_id()</c></seealso></item>
+ <item><c>Filter = </c><seealso marker="logger#type-filter">
+ <c>logger:filter()</c></seealso></item>
+ </list>
+ <p>Handler filters are specified when adding the handler,
or added or removed during runtime with
<seealso marker="logger#add_handler_filter-3">
<c>logger:add_handler_filter/3</c></seealso> and
@@ -605,49 +583,214 @@ logger:debug(#{got => connection_request, id => Id, state => State},
<c>logger:remove_handler_filter/2</c></seealso>,
respectively.</p>
<p>See <seealso marker="#filters">Filters</seealso> for more
- information.</p>
- <p>Default is <c>[]</c>, that is, no filters exist.</p>
+ detailed information.</p>
+ <p>Defaults to <c>[]</c>.</p>
</item>
- <tag><marker id="filter_default"/><c>filter_default = log | stop</c></tag>
+ <tag><c>filter_default = log | stop</c></tag>
<item>
- <p>Specifies what to do with an event if all filters
+ <p>Specifies what happens to a log event if all filters
return <c>ignore</c>, or if no filters exist.</p>
<p>See section <seealso marker="#filters">Filters</seealso>
for more information about how this option is used.</p>
- <p>Default is <c>log</c>.</p>
+ <p>Defaults to <c>log</c>.</p>
</item>
- <tag><c>formatter = {module(),</c><seealso marker="logger#type-formatter_config">
- <c>logger:formatter_config()</c></seealso><c>}</c></tag>
+ <tag><c>formatter = {FormatterModule,FormatterConfig}</c></tag>
<item>
- <p>The formatter which the handler can use for converting
- the log event term to a printable string.</p>
- <p>See <seealso marker="#formatters">Formatters</seealso> for more
- information.</p>
- <p>Default
- is <c>{logger_formatter,DefaultFormatterConfig}</c>, see
+ <p>Specifies a formatter that the handler can use for
+ converting the log event term to a printable string.</p>
+ <list>
+ <item><c>FormatterModule = module()</c></item>
+ <item><c>FormatterConfig = </c>
+ <seealso marker="logger#type-formatter_config">
+ <c>logger:formatter_config()</c></seealso></item>
+ </list>
+ <p>The formatter information is specified when adding the
+ handler. The formatter configuration can be changed during
+ runtime
+ with <seealso marker="logger#update_formatter_config-2">
+ <c>logger:update_formatter_config/2,3</c></seealso>,
+ or the complete formatter information can be overwritten
+ with, for
+ instance, <seealso marker="logger#set_handler_config-3">
+ <c>logger:set_handler_config/3</c></seealso>.</p>
+ <p>See
+ section <seealso marker="#formatters">Formatters</seealso>
+ for more detailed information.</p>
+ <p>Defaults
+ to <c>{logger_formatter,DefaultFormatterConfig}</c>. See
the <seealso marker="logger_formatter">
- <c>logger_formatter(3)</c></seealso>
- manual for information about this formatter and its
- default configuration.</p>
+ <c>logger_formatter(3)</c></seealso> manual page for
+ information about this formatter and its default
+ configuration.</p>
</item>
- <tag><c>HandlerConfig, atom() = term()</c></tag>
- <item>
- <p>Any keys not listed above are considered to be handler
- specific configuration. The configuration of the Kernel
- handlers can be found in
+ <tag><c>config = term()</c></tag>
+ <item>
+ <p>Handler specific configuration, that is, configuration
+ data related to a specific handler implementation.</p>
+ <p>The configuration for the built-in handlers is described
+ in
the <seealso marker="logger_std_h"><c>logger_std_h(3)</c></seealso>
and
<seealso marker="logger_disk_log_h"><c>logger_disk_log_h(3)</c>
</seealso> manual pages.</p>
- </item>
+ </item>
</taglist>
<p>Notice that <c>level</c> and <c>filters</c> are obeyed by
Logger itself before forwarding the log events to each
- handler, while <c>formatter</c> and all handle specific
+ handler, while <c>formatter</c> and all handler specific
options are left to the handler implementation.</p>
- <p>All Logger's built-in handlers will call the given formatter
- before printing.</p>
+ </section>
+
+ <section>
+ <marker id="kernel_config_params"/>
+ <title>Kernel Configuration Parameters</title>
+
+ <p>The following Kernel configuration parameters apply to
+ Logger:</p>
+ <taglist>
+ <tag><marker id="logger_parameter"/><c>logger = [Config]</c></tag>
+ <item>
+ <p>Specifies the configuration
+ for <seealso marker="logger">Logger</seealso>, except the
+ primary log level, which is specified
+ with <seealso marker="#logger_level"><c>logger_level</c></seealso>,
+ and the compatibility
+ with <seealso marker="sasl:error_logging">SASL Error
+ Logging</seealso>, which is specified
+ with <seealso marker="#logger_sasl_compatible">
+ <c>logger_sasl_compatible</c></seealso>.</p>
+ <p>With this parameter, you can modify or disable the default
+ handler, add custom handlers and primary logger filters, and
+ set log levels per module.</p>
+ <p><c>Config</c> is any (zero or more) of the following:</p>
+ <taglist>
+ <tag><c>{handler, default, undefined}</c></tag>
+ <item>
+ <p>Disables the default handler. This allows another
+ application to add its own default handler.</p>
+ <p>Only one entry of this type is allowed.</p>
+ </item>
+ <tag><c>{handler, HandlerId, Module, HandlerConfig}</c></tag>
+ <item>
+ <p>If <c>HandlerId</c> is <c>default</c>, then this entry
+ modifies the default handler, equivalent to calling</p>
+ <pre><seealso marker="logger#set_handler_config-2">
+ logger:set_handler_config(default, Module, HandlerConfig)
+ </seealso></pre>
+ <p>For all other values of <c>HandlerId</c>, this entry
+ adds a new handler, equivalent to calling</p>
+ <pre><seealso marker="logger:add_handler/3">
+ logger:add_handler(HandlerId, Module, HandlerConfig)
+ </seealso></pre>
+ <p>Multiple entries of this type are allowed.</p></item>
+ <tag><c>{filters, FilterDefault, [Filter]}</c></tag>
+ <item>
+ <p>Adds the specified primary filters.</p>
+ <list>
+ <item><c>FilterDefault = log | stop</c></item>
+ <item><c>Filter = {FilterId, {FilterFun, FilterConfig}}</c></item>
+ </list>
+ <p>Equivalent to calling</p>
+ <pre><seealso marker="logger#add_primary_filter/2">
+ logger:add_primary_filter(FilterId, {FilterFun, FilterConfig})
+ </seealso></pre>
+ <p>for each <c>Filter</c>.</p>
+ <p><c>FilterDefault</c> specifies the behaviour if all
+ primary filters return <c>ignore</c>, see
+ section <seealso marker="#filters">Filters</seealso>.</p>
+ <p>Only one entry of this type is allowed.</p>
+ </item>
+ <tag><c>{module_level, Level, [Module]}</c></tag>
+ <item>
+ <p>Sets module log level for the given modules. Equivalent
+ to calling</p>
+ <pre><seealso marker="logger#set_module_level/2">
+ logger:set_module_level(Module, Level)</seealso></pre>
+ <p>for each <c>Module</c>.</p>
+ <p>Multiple entries of this type are allowed.</p>
+ </item>
+ </taglist>
+ <p>See
+ section <seealso marker="#config_examples">Configuration
+ Examples</seealso> for examples using the <c>logger</c>
+ parameter for system configuration.</p>
+ </item>
+ <tag><marker id="logger_level"/>
+ <c>logger_level = Level</c></tag>
+ <item>
+ <p>Specifies the primary log level. See
+ the <seealso marker="kernel_app#logger_level"><c>kernel(6)</c></seealso>
+ manual page for more information about this parameter.</p>
+ </item>
+ <tag><marker id="logger_sasl_compatible"/>
+ <c>logger_sasl_compatible = true | false</c></tag>
+ <item>
+ <p>Specifies Logger's compatibility
+ with <seealso marker="sasl:error_logging">SASL Error
+ Logging</seealso>. See
+ the <seealso marker="kernel_app#logger_sasl_compatible">
+ <c>kernel(6)</c></seealso> manual page for more
+ information about this parameter.</p>
+ </item>
+ </taglist>
+ </section>
+
+ <section>
+ <marker id="config_examples"/>
+ <title>Configuration Examples</title>
+ <p>The value of the Kernel configuration parameter <c>logger</c>
+ is a list of tuples. It is possible to write the term on the
+ command line when starting an erlang node, but as the term
+ grows, a better approach is to use the system configuration
+ file. See
+ the <seealso marker="config"><c>config(4)</c></seealso> manual
+ page for more information about this file.</p>
+ <p>Each of the following examples shows a simple system
+ configuration file that configures Logger according to the
+ description.</p>
+ <p>Modify the default handler to print to a file instead of
+ <c>standard_io</c>:</p>
+ <code>
+[{kernel,
+ [{logger,
+ [{handler, default, logger_std_h, % {handler, HandlerId, Module,
+ #{config => #{type => {file,"log/erlang.log"}}}} % Config}
+ ]}]}].
+ </code>
+ <p>Modify the default handler to print each log event as a
+ single line:</p>
+ <code>
+[{kernel,
+ [{logger,
+ [{handler, default, logger_std_h,
+ #{formatter => {logger_formatter, #{single_line => true}}}}
+ ]}]}].
+ </code>
+ <p>Modify the default handler to print the pid of the logging
+ process for each log event:</p>
+ <code>
+[{kernel,
+ [{logger,
+ [{handler, default, logger_std_h,
+ #{formatter => {logger_formatter,
+ #{template => [time," ",pid," ",msg,"\n"]}}}}
+ ]}]}].
+ </code>
+ <p>Modify the default handler to only print errors and more
+ severe log events to "log/erlang.log", and add another handler
+ to print all log events to "log/debug.log".</p>
+ <code>
+[{kernel,
+ [{logger,
+ [{handler, default, logger_std_h,
+ #{level => error,
+ config => #{type => {file, "log/erlang.log"}}}},
+ {handler, info, logger_std_h,
+ #{level => debug,
+ config => #{type => {file, "log/debug.log"}}}}
+ ]}]}].
+ </code>
</section>
</section>
@@ -687,8 +830,9 @@ logger:debug(#{got => connection_request, id => Id, state => State},
<p>To get log events on the same format as produced
by <c>error_logger_tty_h</c> and <c>error_logger_file_h</c>,
use the default formatter, <c>logger_formatter</c>, with
- configuration parameter <c>legacy_header => true</c>. This is
- also the default.</p>
+ configuration parameter <c>legacy_header</c> set
+ to <c>true</c>. This is the default configuration of
+ the <c>default</c> handler started by Kernel.</p>
</item>
<tag>Default Format of Log Events from OTP</tag>
<item>
@@ -700,12 +844,11 @@ logger:debug(#{got => connection_request, id => Id, state => State},
<item>
<p>By SASL reports we mean supervisor reports, crash reports
and progress reports.</p>
- <p>In earlier releases, these reports were only logged when
- the SASL application was running, and they were printed
- trough specific event handlers
- named <c>sasl_report_tty_h</c>
+ <p>Prior to Erlang/OTP 21.0, these reports were only logged
+ when the SASL application was running, and they were printed
+ trough SASL's own event handlers <c>sasl_report_tty_h</c>
and <c>sasl_report_file_h</c>.</p>
- <p>The destination of these log events were configured by
+ <p>The destination of these log events was configured by
<seealso marker="sasl:sasl_app#deprecated_error_logger_config">SASL
configuration parameters</seealso>.</p>
<p>Due to the specific event handlers, the output format
@@ -716,17 +859,20 @@ logger:debug(#{got => connection_request, id => Id, state => State},
<list>
<item>Supervisor reports, crash reports, and progress reports
are no longer connected to the SASL application.</item>
- <item>Supervisor reports and crash reports are logged by
- default.</item>
- <item>Progress reports are not logged by default, but can be
- enabled with the Kernel configuration
- parameter <seealso marker="kernel_app#logger_progress_reports">
- <c>logger_progress_reports</c></seealso>.</item>
+ <item>Supervisor reports and crash reports are issued
+ as <c>error</c> level log events, and are logged through
+ the default handler started by Kernel.</item>
+ <item>Progress reports are issued as <c>info</c> level log
+ events, and since the default primary log level
+ is <c>notice</c>, these are not logged by default. To
+ enable printing of progress reports, set
+ the <seealso marker="#primary_level">primary log
+ level</seealso> to <c>info</c>.</item>
<item>The output format is the same for all log
events.</item>
</list>
- <p>If the old behaviour is preferred, the Kernel configuation
- parameter <seealso marker="kernel_app:logger_sasl_compatible">
+ <p>If the old behaviour is preferred, the Kernel configuration
+ parameter <seealso marker="kernel_app#logger_sasl_compatible">
<c>logger_sasl_compatible</c></seealso> can be set
to <c>true</c>. The
<seealso marker="sasl:sasl_app#deprecated_error_logger_config">SASL
@@ -734,11 +880,10 @@ logger:debug(#{got => connection_request, id => Id, state => State},
before, and the SASL reports will only be printed if the
SASL application is running, through a second log handler
named <c>sasl</c>.</p>
- <p>All SASL reports have a metadata
- field <c>domain => [beam,erlang,otp,sasl]</c>, which can be
- used, for example, by filters to stop or allow the
- log events.</p>
- <p>See the <seealso marker="sasl:error_logging">SASL User's
+ <p>All SASL reports have a metadata field <c>domain</c> which
+ is set to <c>[otp,sasl]</c>. This field can be
+ used by filters to stop or allow the log events.</p>
+ <p>See section <seealso marker="sasl:error_logging">SASL User's
Guide</seealso> for more information about the old SASL
error logging functionality.</p>
</item>
@@ -749,21 +894,22 @@ logger:debug(#{got => connection_request, id => Id, state => State},
<code>
error_logger:add_report_handler/1,2.
</code>
- <p>This will automatically start the <c>error_logger</c>
- event manager, and add <c>error_logger</c> as a
- handler to <c>logger</c>, with configuration</p>
+ <p>This automatically starts the error logger event manager,
+ and adds <c>error_logger</c> as a handler to Logger, with
+ the following configuration:</p>
<code>
#{level => info,
filter_default => log,
filters => []}.
</code>
- <p>Notice that this handler will ignore events that do not
- originate from the <c>error_logger</c> 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.</p>
- <p>Also notice that <c>error_logger</c> is not overload
- protected.</p>
+ <note>
+ <p>This handler ignores events that do not originate from
+ the <c>error_logger</c> 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.</p>
+ <p>The handler is not overload protected.</p>
+ </note>
</item>
</taglist>
</section>
@@ -771,100 +917,108 @@ error_logger:add_report_handler/1,2.
<section>
<title>Error Handling</title>
- <p>Log data is expected to be either a format string and
- arguments, a string
- (<seealso marker="stdlib:unicode#type-chardata">
- <c>unicode:chardata()</c></seealso>), or a report (map or
- key-value list) which can be converted to a format string and
- 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. 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.</p>
- <p>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.</p>
+ <p>Logger does, to a certain extent, check its input data before
+ forwarding a log event to filters and handlers. It does,
+ however, not evaluate report callbacks, or check the validity of
+ format strings and arguments. This means that all filters and
+ handlers 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.</p>
<p>If a filter or handler still crashes, Logger will remove the
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.</p>
+ the crash reason and other details is also issued.</p>
+ <p>See section <seealso marker="#log_message">Log
+ Message</seealso> for more information about report callbacks
+ and valid forms of log messages.</p>
</section>
<section>
- <title>Example: add a handler to log debug events to file</title>
+ <title>Example: Add a handler to log debug events to file</title>
<p>When starting an Erlang node, the default behaviour is that all
- log events with level info and above are logged to the
- terminal. In order to also log debug events, you can either
- change the global log level to <c>debug</c> 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.</p>
- <p>First, we add an instance of <c>logger_std_h</c> with
- type <c>{file,File}</c>, and we set the handler's level
- to <c>debug</c>:</p>
+ log events on level info or more severe, are logged to the
+ terminal via the default handler. To also log debug events, you
+ can either change the primary log level to <c>debug</c>:</p>
<pre>
-1> <input>Config = #{level => debug, logger_std_h => #{type => {file,"./debug.log"}}}.</input>
-#{logger_std_h => #{type => {file,"./debug.log"}},
- level => debug}
-2> <input>logger:add_handler(debug_handler,logger_std_h,Config).</input>
+1> <input>logger:set_primary_config(level, debug).</input>
ok</pre>
- <p>By default, the handler receives all events
- (<c>filter_default=log</c>, see
- section <seealso marker="#filters">Filters</seealso> for more
- details), so we need to add a filter to stop all non-debug
- events. The built-in
- filter <seealso marker="logger_filters#level-2">
- <c>logger_filters:level/2</c></seealso>
- is used for this:</p>
+ <p>or set the level for one or a few modules only:</p>
<pre>
-3> <input>logger:add_handler_filter(debug_handler,stop_non_debug,
- {fun logger_filters:level/2,{stop,neq,debug}}).</input>
+2> <input>logger:set_module_level(mymodule, debug).</input>
ok</pre>
- <p>And finally, we need to make sure that Logger itself allows
- debug events. This can either be done by setting the global
- log level:</p>
+ <p>This allows debug events to pass through to the default handler,
+ and be printed to the terminal as well. If there are many debug
+ events, it can be useful to print these to a file instead.</p>
+ <p>First, set the log level of the default handler to <c>info</c>,
+ preventing it from printing debug events to the terminal:</p>
<pre>
-4> <input>logger:set_logger_config(level,debug).</input>
+3> <input>logger:set_handler_config(default, level, info).</input>
ok</pre>
- <p>Or by allowing debug events from one or a few modules only:</p>
+ <p>Then, add a new handler which prints to file. You can use the
+ handler
+ module <seealso marker="logger_std_h"><c>logger_std_h</c></seealso>,
+ and specify type <c>{file,File}</c>. The default handler level
+ is <c>all</c>, so you don't need to specify that:</p>
+ <pre>
+4> <input>Config = #{config => #{type => {file,"./debug.log"}}}.</input>
+#{config => #{type => {file,"./debug.log"}}}
+5> <input>logger:add_handler(debugger, logger_std_h, Config).</input>
+ok</pre>
+ <p>Since <c>filter_default</c> defaults to <c>log</c>, this
+ handler now receives all log events. If you want debug events
+ only in the file, you must add a filter to stop all non-debug
+ events. The built-in
+ filter <seealso marker="logger_filters#level-2">
+ <c>logger_filters:level/2</c></seealso>
+ can do this:</p>
<pre>
-5> <input>logger:set_module_level(mymodule,debug).</input>
+6> <input>logger:add_handler_filter(debugger, stop_non_debug,
+ {fun logger_filters:level/2, {stop, neq, debug}}).</input>
ok</pre>
+ <p>See section <seealso marker="#filters">Filters</seealso> for
+ more information about the filters and the <c>filter_default</c>
+ configuration parameter.</p>
</section>
<section>
- <title>Example: implement a handler</title>
- <p>The only requirement that a handler MUST fulfill is to export
- the following function:</p>
- <code>log(logger:log_event(),logger:config()) -> ok</code>
- <p>It can optionally also implement the following callbacks:</p>
- <code>
-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()}
- </code>
- <p>When <c>logger:add_handler(Id,Module,Config)</c> is called,
+ <title>Example: Implement a handler</title>
+ <p>Section <seealso marker="logger#handler_callback_functions">Handler
+ Callback Functions</seealso> in the logger(3) manual page
+ describes the callback functions that can be implemented for a
+ Logger handler.</p>
+ <p>A handler callback module must export:</p>
+ <list>
+ <item><c>log(Log, Config)</c></item>
+ </list>
+ <p>It can optionally also export some, or all, of the following:</p>
+ <list>
+ <item><c>adding_handler(Config)</c></item>
+ <item><c>removing_handler(Config)</c></item>
+ <item><c>changing_config(OldConfig, NewConfig)</c></item>
+ </list>
+ <p>When a handler is added, by for example a call
+ to <seealso marker="logger#add_handler-3">
+ <c>logger:add_handler(Id, HModule, Config)</c></seealso>,
Logger first calls <c>HModule:adding_handler(Config)</c>. If
- this function returns <c>{ok,NewConfig}</c>, Logger
- writes <c>NewConfig</c> to the configuration database, and
+ this function returns <c>{ok,Config1}</c>, Logger
+ writes <c>Config1</c> to the configuration database, and
the <c>logger:add_handler/3</c> call returns. After this, the
handler is installed and must be ready to receive log events as
calls to <c>HModule:log/2</c>.</p>
<p>A handler can be removed by calling
- <c>logger:remove_handler(Id)</c>. Logger calls
+ <seealso marker="logger#remove_handler-1">
+ <c>logger:remove_handler(Id)</c></seealso>. Logger calls
<c>HModule:removing_handler(Config)</c>, and removes the
handler's configuration from the configuration database.</p>
- <p>When <c>logger:set_handler_config/2,3</c>
- or <c>logger:update_handler_config/2</c> is called, Logger
- calls <c>HModule:changing_config(OldConfig,NewConfig)</c>. If
- this function returns <c>{ok,NewConfig}</c>, Logger
- writes <c>NewConfig</c> to the configuration database.</p>
+ <p>When <seealso marker="logger#set_handler_config-2">
+ <c>logger:set_handler_config/2,3</c></seealso>
+ or <seealso marker="logger#update_handler_config/2">
+ <c>logger:update_handler_config/2</c></seealso> is called,
+ Logger
+ calls <c>HModule:changing_config(OldConfig, NewConfig)</c>. If
+ this function returns <c>{ok,NewConfig1}</c>, Logger
+ writes <c>NewConfig1</c> to the configuration database.</p>
<p>A simple handler that prints to the terminal can be implemented
as follows:</p>
@@ -872,11 +1026,11 @@ changing_config(logger:config(),logger:config()) -> {ok,logger:config()} | {erro
-module(myhandler).
-export([log/2]).
-log(LogEvent,#{formatter:={FModule,FConfig}) ->
- io:put_chars(FModule:format(LogEvent,FConfig)).
+log(LogEvent, #{formatter := {FModule, FConfig}) ->
+ io:put_chars(FModule:format(LogEvent, FConfig)).
</code>
- <p>A simple handler which prints to file could be implemented like
+ <p>A simple handler which prints to file can be implemented like
this:</p>
<code>
-module(myhandler).
@@ -884,28 +1038,29 @@ log(LogEvent,#{formatter:={FModule,FConfig}) ->
-export([init/1, handle_call/3, handle_cast/2, terminate/2]).
adding_handler(Config) ->
- {ok,Fd} = file:open(File,[append,{encoding,utf8}]),
- {ok,Config#{myhandler_fd => Fd}}.
+ {ok, Fd} = file:open(File, [append, {encoding, utf8}]),
+ {ok, Config#{myhandler_fd => Fd}}.
-removing_handler(#{myhandler_fd:=Fd}) ->
+removing_handler(#{myhandler_fd := Fd}) ->
_ = file:close(Fd),
ok.
-log(LogEvent,#{myhandler_fd:=Fd,formatter:={FModule,FConfig}}) ->
- io:put_chars(Fd,FModule:format(LogEvent,FConfig)).
+log(LogEvent,#{myhandler_fd := Fd, formatter := {FModule, FConfig}}) ->
+ io:put_chars(Fd, FModule:format(LogEvent, FConfig)).
</code>
- <note><p>The above handlers do not have any overload
- protection, and all log events are printed directly from the
- client process.</p></note>
-
- <p>For information and examples of overload protection, please
- refer to
- section <seealso marker="#overload_protection">Protecting the
- Handler from Overload</seealso>, and the implementation
- of <seealso marker="logger_std_h"><c>logger_std_h(3)</c></seealso>
- and <seealso marker="logger_disk_log_h"><c>logger_disk_log_h(3)</c>
- </seealso>.</p>
+ <note>
+ <p>The above handlers do not have any overload
+ protection, and all log events are printed directly from the
+ client process.</p>
+ <p>For information and examples of overload protection, please
+ refer to
+ section <seealso marker="#overload_protection">Protecting the
+ Handler from Overload</seealso>, and the implementation
+ of <seealso marker="logger_std_h"><c>logger_std_h</c></seealso>
+ and <seealso marker="logger_disk_log_h"><c>logger_disk_log_h</c>
+ </seealso>.</p>
+ </note>
<p>Below is a simpler example of a handler which logs through one
single process.</p>
@@ -915,33 +1070,33 @@ log(LogEvent,#{myhandler_fd:=Fd,formatter:={FModule,FConfig}}) ->
-export([init/1, handle_call/3, handle_cast/2, terminate/2]).
adding_handler(Config) ->
- {ok,Pid} = gen_server:start(?MODULE,Config),
- {ok,Config#{myhandler_pid => Pid}}.
+ {ok, Pid} = gen_server:start(?MODULE, Config),
+ {ok, Config#{myhandler_pid => Pid}}.
-removing_handler(#{myhandler_pid:=Pid}) ->
+removing_handler(#{myhandler_pid := Pid}) ->
gen_server:stop(Pid).
-log(LogEvent,#{myhandler_pid:=Pid} = Config) ->
- gen_server:cast(Pid,{log,LogEvent,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}]),
- {ok,#{file => File, fd => Fd}}.
+init(#{myhandler_file := File}) ->
+ {ok, Fd} = file:open(File, [append, {encoding, utf8}]),
+ {ok, #{file => File, fd => Fd}}.
-handle_call(_,_,State) ->
- {reply,{error,bad_request},State}.
+handle_call(_, _, State) ->
+ {reply, {error, bad_request}, State}.
-handle_cast({log,LogEvent,Config},#{fd:=Fd} = State) ->
- do_log(Fd,LogEvent,Config),
- {noreply,State}.
+handle_cast({log, LogEvent, Config}, #{fd := Fd} = State) ->
+ do_log(Fd, LogEvent, Config),
+ {noreply, State}.
-terminate(Reason,#{fd:=Fd}) ->
+terminate(Reason, #{fd := Fd}) ->
_ = file:close(Fd),
ok.
-do_log(Fd,LogEvent,#{formatter:={FModule,FConfig}}) ->
- String = FModule:format(LogEvent,FConfig),
- io:put_chars(Fd,String).
+do_log(Fd, LogEvent, #{formatter := {FModule, FConfig}}) ->
+ String = FModule:format(LogEvent, FConfig),
+ io:put_chars(Fd, String).
</code>
</section>
@@ -985,7 +1140,7 @@ do_log(Fd,LogEvent,#{formatter:={FModule,FConfig}}) ->
level below the <c>toggle_sync_qlen</c> threshold, asynchronous
operation is resumed. The switch from asynchronous to synchronous
mode will force the logging tempo of few busy senders to slow down,
- but can not protect the handler sufficiently in situations of many
+ but cannot protect the handler sufficiently in situations of many
concurrent senders.</p>
</item>
<tag><c>drop_new_reqs_qlen</c></tag>
@@ -1044,11 +1199,11 @@ do_log(Fd,LogEvent,#{formatter:={FModule,FConfig}}) ->
<p>A configuration example:</p>
<code type="none">
logger:add_handler(my_standard_h, logger_std_h,
- #{logger_std_h =>
- #{type => {file,"./system_info.log"},
- toggle_sync_qlen => 100,
- drop_new_reqs_qlen => 1000,
- flush_reqs_qlen => 2000}}).
+ #{config =>
+ #{type => {file,"./system_info.log"},
+ toggle_sync_qlen => 100,
+ drop_new_reqs_qlen => 1000,
+ flush_reqs_qlen => 2000}}).
</code>
</section>
@@ -1086,10 +1241,10 @@ logger:add_handler(my_standard_h, logger_std_h,
<code type="none">
logger:add_handler(my_disk_log_h, logger_disk_log_h,
#{disk_log_opts =>
- #{file => "./my_disk_log"},
- logger_disk_log_h =>
- #{burst_limit_size => 10,
- burst_window_time => 500}}).
+ #{file => "./my_disk_log"},
+ config =>
+ #{burst_limit_size => 10,
+ burst_window_time => 500}}).
</code>
</section>
diff --git a/lib/kernel/doc/src/logger_disk_log_h.xml b/lib/kernel/doc/src/logger_disk_log_h.xml
index 20b49b8ca0..63c29cb010 100644
--- a/lib/kernel/doc/src/logger_disk_log_h.xml
+++ b/lib/kernel/doc/src/logger_disk_log_h.xml
@@ -44,7 +44,7 @@
the handler configuration.</p>
<p>The default standard handler,
<seealso marker="logger_std_h"><c>logger_std_h</c></seealso>, can be
- replaced by a disk_log handler at startup of the Kernel application.
+ replaced by a disk_log handler at start up of the Kernel application.
See an example of this below.</p>
<p>The handler has an overload protection mechanism that will keep the handler
process and the Kernel application alive during a high load of log
@@ -60,7 +60,7 @@
</seealso>, as well as handler specific parameters.</p>
<p>The settings for the disk_log log file should be specified with the
key <c>disk_log_opts</c>. These settings are a subset of the disk_log
- datatype
+ data type
<seealso marker="disk_log#open-1"><c>dlog_option()</c></seealso>.</p>
<p>Parameters in the <c>disk_log_opts</c> map:</p>
<taglist>
@@ -81,7 +81,7 @@
log.</item>
</taglist>
<p>Specific configuration for the handler (represented as a sub map)
- is specified with the key <c>logger_disk_log_h</c>. It may contain the
+ is specified with the key <c>config</c>. It may contain the
following parameter:</p>
<taglist>
<tag><c>filesync_repeat_interval</c></tag>
@@ -93,7 +93,7 @@
since the last sync. The default value is <c>5000</c> milliseconds.
If <c>no_repeat</c> is set as value, the repeated sync operation is
disabled. The user can also call the
- <seealso marker="logger_disk_log_h#disk_log_sync-1"><c>disk_log_sync/1</c>
+ <seealso marker="logger_disk_log_h#sync-1"><c>sync/1</c>
</seealso> function to perform a disk_log sync.</p></item>
</taglist>
<p>There are a number of other configuration parameters available, that are
@@ -117,7 +117,7 @@ logger:add_handler(my_disk_log_h, logger_disk_log_h,
type => wrap,
max_no_files => 4,
max_no_bytes => 10000},
- logger_disk_log_h =>
+ config =>
#{filesync_repeat_interval => 1000}}).
</code>
<p>In order to use the disk_log handler instead of the default standard
@@ -125,14 +125,14 @@ logger:add_handler(my_disk_log_h, logger_disk_log_h,
use disk_log. Example:</p>
<code type="none">
erl -kernel logger '[{handler,default,logger_disk_log_h,
- #{ disk_log_opts => #{ file => "./system_disk_log"}}}]'
+ #{disk_log_opts => #{file => "./system_disk_log"}}}]'
</code>
</description>
<funcs>
<func>
- <name name="disk_log_sync" arity="1" clause_i="1"/>
+ <name name="sync" arity="1" clause_i="1"/>
<fsummary>Writes buffered data to disk.</fsummary>
<desc>
<p>Write buffered data to disk.</p>
@@ -143,9 +143,9 @@ erl -kernel logger '[{handler,default,logger_disk_log_h,
<section>
<title>See Also</title>
- <p><seealso marker="logger"><c>logger(3)</c></seealso></p>
- <p><seealso marker="logger_std_h"><c>logger_std_h(3)</c></seealso></p>
- <p><seealso marker="disk_log"><c>disk_log(3)</c></seealso></p>
+ <p><seealso marker="logger"><c>logger(3)</c></seealso>,
+ <seealso marker="logger_std_h"><c>logger_std_h(3)</c></seealso>,
+ <seealso marker="disk_log"><c>disk_log(3)</c></seealso></p>
</section>
</erlref>
diff --git a/lib/kernel/doc/src/logger_filters.xml b/lib/kernel/doc/src/logger_filters.xml
index f92181ea3f..90f1fcc270 100644
--- a/lib/kernel/doc/src/logger_filters.xml
+++ b/lib/kernel/doc/src/logger_filters.xml
@@ -36,15 +36,15 @@
<modulesummary>Filters to use with Logger.</modulesummary>
<description>
- <p>All functions exported from this module can be used as logger
+ <p>All functions exported from this module can be used as primary
or handler
- filters. See <seealso marker="logger#add_logger_filter-2">
- <c>logger:add_logger_filter/2</c></seealso>
+ filters. See <seealso marker="logger#add_primary_filter-2">
+ <c>logger:add_primary_filter/2</c></seealso>
and <seealso marker="logger#add_handler_filter-3">
<c>logger:add_handler_filter/3</c></seealso> for more information
about how filters are added.</p>
- <p>Filters are removed with <seealso marker="logger#remove_logger_filter-1">
- <c>logger:remove_logger_filter/1</c></seealso>
+ <p>Filters are removed with <seealso marker="logger#remove_primary_filter-1">
+ <c>logger:remove_primary_filter/1</c></seealso>
and <seealso marker="logger#remove_handler_filter-2">
<c>logger:remove_handler_filter/2</c></seealso>.</p>
</description>
@@ -64,18 +64,18 @@
<p>A domain field must be a list of atoms, creating smaller
and more specialized domains as the list grows longer. The
- biggest domain is <c>[]</c>, which comprices all
- possible domains.</p>
+ greatest domain is <c>[]</c>, which comprises all possible
+ domains.</p>
<p>For example, consider the following domains:</p>
<pre>
-D1 = [beam,erlang,otp]
-D2 = [beam,erlang,otp,sasl]</pre>
+D1 = [otp]
+D2 = [otp, sasl]</pre>
- <p><c>D1</c> is the biggest of the two, and is said to be a
+ <p><c>D1</c> is the greatest of the two, and is said to be a
super-domain of <c>D2</c>. <c>D2</c> is a
sub-domain <c>D1</c>. Both <c>D1</c> and <c>D2</c> are
- sub-domains of <c>[]</c></p>
+ sub-domains of <c>[]</c>.</p>
<p>The above domains are used for logs originating from
Erlang/OTP. D1 specifies that the log event comes from
@@ -86,50 +86,50 @@ D2 = [beam,erlang,otp,sasl]</pre>
<p>The <c><anno>Extra</anno></c> parameter to
the <c>domain/2</c> function is specified when adding the
- filter via <seealso marker="logger#add_logger_filter-2">
- <c>logger:add_logger_filter/2</c></seealso>
+ filter via <seealso marker="logger#add_primary_filter-2">
+ <c>logger:add_primary_filter/2</c></seealso>
or <seealso marker="logger#add_handler_filter-3">
<c>logger:add_handler_filter/3</c></seealso>.</p>
- <p>The filter compares the value of the <c>domain</c> field
- in the log event's metadata (<c>Domain</c>)
- to <c><anno>MatchDomain</anno></c> as follows:</p>
+ <p>The filter compares the value of the <c>domain</c> field in
+ the log event's metadata (<c>Domain</c>) against
+ <c><anno>MatchDomain</anno></c>. The filter matches if the
+ value of <c>Compare</c> is:</p>
<taglist>
- <tag><c><anno>Compare</anno> = sub</c></tag>
+ <tag><c>sub</c></tag>
<item>
- <p>The filter matches if <c>Domain</c> is equal to or
- a sub-domain of <c>MatchDomain</c>, that is,
- if <c>MatchDomain</c> is a prefix of <c>Domain</c>.</p>
+ <p>and <c>Domain</c> is equal to or a sub-domain
+ of <c>MatchDomain</c>, that is, if <c>MatchDomain</c> is
+ a prefix of <c>Domain</c>.</p>
</item>
- <tag><c><anno>Compare</anno> = super</c></tag>
+ <tag><c>super</c></tag>
<item>
- <p>The filter matches if <c>Domain</c> is equal to or a
- super-domain of <c>MatchDomain</c>, that is,
- if <c>Domain</c> is a prefix of <c>MatchDomain</c>.</p>
+ <p>and <c>Domain</c> is equal to or a super-domain
+ of <c>MatchDomain</c>, that is, if <c>Domain</c> is a
+ prefix of <c>MatchDomain</c>.</p>
</item>
- <tag><c><anno>Compare</anno> = equal</c></tag>
+ <tag><c>equal</c></tag>
<item>
- <p>The filter matches if <c>Domain</c> is equal
- to <c>MatchDomain</c>.</p>
+ <p>and <c>Domain</c> is equal to <c>MatchDomain</c>.</p>
</item>
- <tag><c><anno>Compare</anno> = not_equal</c></tag>
+ <tag><c>not_equal</c></tag>
<item>
- <p>The filter matches if <c>Domain</c> is not equal
- to <c>MatchDomain</c>, or if there is no domain field in
- metadata.</p>
+ <p>and <c>Domain</c> differs from <c>MatchDomain</c>, or
+ if there is no domain field in metadata.</p>
</item>
- <tag><c><anno>Compare</anno> = undefined</c></tag>
- <item><p>The filter matches if there is no domain field in
- metadata. In this case <c><anno>MatchDomain</anno></c>
- must be set to <c>[]</c>.</p>
+ <tag><c>undefined</c></tag>
+ <item>
+ <p>and there is no domain field in metadata. In this
+ case <c><anno>MatchDomain</anno></c> must be set
+ to <c>[]</c>.</p>
</item>
</taglist>
- <p>If the filter matches and <c><anno>Action</anno> = log</c>,
- the log event is allowed. If the filter matches
- and <c><anno>Action</anno> = stop</c>, the log event is
- stopped.</p>
+ <p>If the filter matches and <c><anno>Action</anno></c> is
+ <c>log</c>, the log event is allowed. If the filter matches
+ and <c><anno>Action</anno></c> is <c>stop</c>, the log event
+ is stopped.</p>
<p>If the filter does not match, it returns <c>ignore</c>,
meaning that other filters, or the value of the
@@ -137,16 +137,16 @@ D2 = [beam,erlang,otp,sasl]</pre>
event is allowed or not.</p>
<p>Log events that do not contain any domain field, match only
- when <c><anno>Compare</anno> = undefined</c>
- or <c><anno>Compare</anno> = not_equal</c>.</p>
+ when <c><anno>Compare</anno></c> is equal
+ to <c>undefined</c> or <c>not_equal</c>.</p>
- <p>Example: stop all events with
- domain <c>[beam,erlang,otp,sasl|_]</c></p>
+ <p>Example: stop all events with domain <c>[otp,
+ sasl | _]</c></p>
<code>
-logger:set_handler_config(h1,filter_default,log). % this is the default
-Filter = {fun logger_filters:domain/2,{stop,sub,[beam,erlang,otp,sasl]}}.
-logger:add_handler_filter(h1,no_sasl,Filter).
+logger:set_handler_config(h1, filter_default, log). % this is the default
+Filter = {fun logger_filters:domain/2, {stop, sub, [otp, sasl]}}.
+logger:add_handler_filter(h1, no_sasl, Filter).
ok</code>
</desc>
</func>
@@ -157,34 +157,44 @@ ok</code>
<desc>
<p>This filter provides a way of filtering log events based
on the log level. It matches log events by comparing the
- log level with a predefined <c>MatchLevel</c></p>
+ log level with a specified <c>MatchLevel</c></p>
<p>The <c><anno>Extra</anno></c> parameter is specified when
adding the filter
- via <seealso marker="logger#add_logger_filter-2">
- <c>logger:add_logger_filter/2</c></seealso>
+ via <seealso marker="logger#add_primary_filter-2">
+ <c>logger:add_primary_filter/2</c></seealso>
or <seealso marker="logger#add_handler_filter-3">
<c>logger:add_handler_filter/3</c></seealso>.</p>
<p>The filter compares the value of the event's log level
(<c>Level</c>) to <c><anno>MatchLevel</anno></c> by
calling <seealso marker="logger#compare_levels-2">
- <c>logger:compare_levels(Level,MatchLevel) -> CmpRet</c></seealso>. It
- matches the event if:</p>
-
- <list>
- <item><c>CmpRet = eq</c> and <c><anno>Operator</anno> =
- eq | lteq | gteq</c></item>
- <item><c>CmpRet = lt</c> and <c><anno>Operator</anno> =
- lt | lteq | neq</c></item>
- <item><c>CmpRet = gt</c> and <c><anno>Operator</anno> =
- gt | gteq | neq</c></item>
- </list>
-
- <p>If the filter matches and <c><anno>Action</anno> =
- log</c>, the log event is allowed. If the filter matches
- and <c><anno>Action</anno> = stop</c>, the log event is
- stopped.</p>
+ <c>logger:compare_levels(Level, MatchLevel)</c></seealso>.
+ The filter matches if the value
+ of <c><anno>Operator</anno></c> is:</p>
+
+ <taglist>
+ <tag><c>neq</c></tag>
+ <item><p>and the compare function returns <c>lt</c>
+ or <c>gt</c>.</p></item>
+ <tag><c>eq</c></tag>
+ <item><p>and the compare function returns <c>eq</c>.</p></item>
+ <tag><c>lt</c></tag>
+ <item><p>and the compare function returns <c>lt</c>.</p></item>
+ <tag><c>gt</c></tag>
+ <item><p>and the compare function returns <c>gt</c>.</p></item>
+ <tag><c>lteq</c></tag>
+ <item><p>and the compare function returns <c>lt</c>
+ or <c>eq</c>.</p></item>
+ <tag><c>gteq</c></tag>
+ <item><p>and the compare function returns <c>gt</c>
+ or <c>eq</c>.</p></item>
+ </taglist>
+
+ <p>If the filter matches and <c><anno>Action</anno></c> is
+ <c>log</c>, the log event is allowed. If the filter
+ matches and <c><anno>Action</anno></c> is <c>stop</c>, the
+ log event is stopped.</p>
<p>If the filter does not match, it returns <c>ignore</c>,
meaning that other filters, or the value of the
@@ -194,9 +204,9 @@ ok</code>
<p>Example: only allow debug level log events</p>
<code>
-logger:set_handler_config(h1,filter_default,stop).
-Filter = {fun logger_filters:level/2,{log,eq,debug}}.
-logger:add_handler_filter(h1,debug_only,Filter).
+logger:set_handler_config(h1, filter_default, stop).
+Filter = {fun logger_filters:level/2, {log, eq, debug}}.
+logger:add_handler_filter(h1, debug_only, Filter).
ok</code>
</desc>
</func>
@@ -208,9 +218,9 @@ ok</code>
<p>This filter matches all progress reports
from <c>supervisor</c> and <c>application_controller</c>.</p>
- <p>If <c><anno>Extra</anno> = log</c>, the progress reports
- are allowed. If <c><anno>Extra</anno> = stop</c>, the
- progress reports are stopped.</p>
+ <p>If <c><anno>Extra</anno></c> is <c>log</c>, the progress
+ reports are allowed. If <c><anno>Extra</anno></c>
+ is <c>stop</c>, the progress reports are stopped.</p>
<p>The filter returns <c>ignore</c> for all other log events.</p>
</desc>
@@ -223,9 +233,9 @@ ok</code>
<p>This filter matches all events originating from a process
that has its group leader on a remote node.</p>
- <p>If <c><anno>Extra</anno> = log</c>, the matching events
- are allowed. If <c><anno>Extra</anno> = stop</c>, the
- matching events are stopped.</p>
+ <p>If <c><anno>Extra</anno></c> is <c>log</c>, the matching
+ events are allowed. If <c><anno>Extra</anno></c>
+ is <c>stop</c>, the matching events are stopped.</p>
<p>The filter returns <c>ignore</c> for all other log events.</p>
</desc>
@@ -233,6 +243,12 @@ ok</code>
</funcs>
+ <section>
+ <title>See Also</title>
+ <p>
+ <seealso marker="logger"><c>logger(3)</c></seealso>
+ </p>
+ </section>
</erlref>
diff --git a/lib/kernel/doc/src/logger_formatter.xml b/lib/kernel/doc/src/logger_formatter.xml
index 02f89b26be..59f5dbe367 100644
--- a/lib/kernel/doc/src/logger_formatter.xml
+++ b/lib/kernel/doc/src/logger_formatter.xml
@@ -36,12 +36,15 @@
<modulesummary>Default formatter for Logger.</modulesummary>
<description>
- <p>Each log handler has a configured formatter specified as a
+ <p>Each Logger 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
(<seealso marker="stdlib:unicode#type-chardata"><c>unicode:chardata()</c>
- </seealso>) which can be written to the output
- device of the handler.</p>
+ </seealso>) which can be written to the output device of the
+ handler. See
+ sections <seealso marker="logger_chapter#handlers">Handlers</seealso>
+ and <seealso marker="logger_chapter#formatters">Formatters</seealso>
+ in the Kernel User's Guide for more information.</p>
<p><c>logger_formatter</c> is the default formatter used by
Logger.</p>
</description>
@@ -55,7 +58,8 @@
<seealso marker="stdlib:maps">map</seealso>, and the
following keys can be set as configuration parameters:</p>
<taglist>
- <tag><c>chars_limit = pos_integer() | unlimited</c></tag>
+ <tag><marker id="chars_limit"/>
+ <c>chars_limit = integer() > 0 | unlimited</c></tag>
<item>
<p>A positive integer representing the value of the option
with the same name to be used when calling
@@ -65,14 +69,8 @@
for each log event. Notice that this is a soft limit. For a
hard truncation limit, see option <c>max_size</c>.</p>
<p>Defaults to <c>unlimited</c>.</p>
- <note>
- <p><c>chars_limit</c> has no effect on log messages on
- string form. These are expected to be short, but can
- still be truncated by the <c>max_size</c>
- parameter.</p>
- </note>
</item>
- <tag><marker id="depth"/><c>depth = pos_integer() | unlimited</c></tag>
+ <tag><marker id="depth"/><c>depth = integer() > 0 | unlimited</c></tag>
<item>
<p>A positive integer representing the maximum depth to
which terms shall be printed by this formatter. Format
@@ -83,26 +81,23 @@
<seealso marker="stdlib:io#format-2">io:format/2,3</seealso>
in STDLIB.</p>
<p>Defaults to <c>unlimited</c>.</p>
- <note>
- <p><c>depth</c> has no effect on log messages on string
- form. These are expected to be short, but can still be
- truncated by the <c>max_size</c> parameter.</p>
- </note>
</item>
<tag><c>legacy_header = boolean()</c></tag>
<item>
<p>If set to <c>true</c> a header field is added to
logger_formatter's part of <c>Metadata</c>. The value of
this field is a string similar to the header created by
- the old <c>error_logger</c> event handlers. It can be
- included in the log event by adding the
- tuple <c>{logger_formatter,header}</c> to the
+ the
+ old <seealso marker="error_logger"><c>error_logger</c></seealso>
+ event handlers. It can be included in the log event by
+ adding the list <c>[logger_formatter,header]</c> to the
template. See the description of
the <seealso marker="#type-template"><c>template()</c></seealso>
type for more information.</p>
<p>Defaults to <c>false</c>.</p>
</item>
- <tag><c>max_size = pos_integer() | unlimited</c></tag>
+ <tag><marker id="max_size"/>
+ <c>max_size = integer() > 0 | unlimited</c></tag>
<item>
<p>A positive integer representing the absolute maximum size a
string returned from this formatter can have. If the
@@ -110,12 +105,12 @@
by <c>chars_limit</c> or <c>depth</c>, it is truncated.</p>
<p>Defaults to <c>unlimited</c>.</p>
</item>
- <tag><c>report_cb = fun((</c><seealso marker="logger#type-report"><c>logger:report()</c></seealso><c>) -> {</c><seealso marker="stdlib:io#type-format"><c>io:format()</c></seealso><c>,[term()]})</c></tag>
+ <tag><c>report_cb = fun((</c><seealso marker="logger#type-report"><c>logger:report()</c></seealso><c>) -> {</c><seealso marker="stdlib:io#type-format"><c>io:format()</c></seealso><c>, [term()]})</c></tag>
<item>
<p>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
+ metadata for the log event. If no report callback exists
in metadata, <c>logger_formatter</c> will
use <seealso marker="logger#format_report-1">
<c>logger:format_report/1</c></seealso> as default
@@ -131,12 +126,14 @@
<tag><c>single_line = boolean()</c></tag>
<item>
<p>If set to <c>true</c>, all newlines in the message are
- replaced with <c>", "</c>, and whitespaces following
- directly after newlines are removed. Note that newlines
+ replaced with <c>", "</c>, and white spaces following
+ directly after newlines are removed. Notice that newlines
added by the <c>template</c> parameter are not replaced.</p>
<p>Defaults to <c>true</c>.</p>
</item>
- <tag><c>template = </c><seealso marker="#type-template"><c>template()</c></seealso></tag>
+ <tag><marker id="template"/>
+ <c>template = </c><seealso marker="#type-template"><c>template()</c>
+ </seealso></tag>
<item>
<p>The template describes how the formatted string is
composed by combining different data values from the log
@@ -184,31 +181,42 @@
</desc>
</datatype>
<datatype>
+ <name name="metakey"/>
+ <desc>
+ <p></p>
+ </desc>
+ </datatype>
+ <datatype>
<name name="template"/>
<desc>
- <p>The template is a list of atoms, tuples and strings. The
+ <p>The template is a list of atoms, atom lists, tuples and strings. The
atoms <c>level</c> or <c>msg</c>, are treated as
placeholders for the severity level and the log message,
- respectively. Other atoms or tuples are interpreted as
+ respectively. Other atoms or atom lists are interpreted as
placeholders for metadata, where atoms are expected to match
- top level keys, and tuples represent paths to sub keys when
+ top level keys, and atom lists represent paths to sub keys when
the metadata is a nested map. For example the
- tuple <c>{key1,key2}</c> is replaced by the value of
+ list <c>[key1,key2]</c> is replaced by the value of
the <c>key2</c> field in the nested map below. The
atom <c>key1</c> on its own is replaced by the complete
value of the <c>key1</c> field. The values are converted to
strings.</p>
-<code>
-#{key1=>#{key2=>my_value,
- ...}
+ <code>
+#{key1 => #{key2 => my_value,
+ ...}
...}</code>
- <p>Strings in the template are printed literally.</p>
- <p>The default template differs depending on the values
- of <c>legacy_header</c>
- and <c>single_line</c>:</p>
+ <p>Tuples in the template express if-exist tests for metadata
+ keys. For example, the following tuple says that
+ if <c>key1</c> exists in the metadata map,
+ print <c>"key1=Value"</c>, where <c>Value</c> is the value
+ that <c>key1</c> is associated with in the metadata map. If
+ <c>key1</c> does not exist, print nothing.</p>
+ <code>
+{key1, ["key1=",key1], []}</code>
+ <p>Strings in the template are printed literally.</p>
<p>The default value for the <c>template</c> configuration
parameter depends on the value of the <c>single_line</c>
and <c>legacy_header</c> configuration parameters as
@@ -216,13 +224,13 @@
<p>The log event used in the examples is:</p>
<code>
-?LOG_ERROR("name: ~p~nexit_reason: ~p",[my_name,"It crashed"])</code>
+?LOG_ERROR("name: ~p~nexit_reason: ~p", [my_name, "It crashed"])</code>
<taglist>
- <tag><c>legacy_header=true, single_line=false</c></tag>
+ <tag><c>legacy_header = true, single_line = false</c></tag>
<item>
<p>Default
- template: <c>[{logger_formatter,header},"\n",msg,"\n"]</c></p>
+ template: <c>[[logger_formatter,header],"\n",msg,"\n"]</c></p>
<p>Example log entry:</p>
<code type="none">
@@ -231,15 +239,16 @@ name: my_name
exit_reason: "It crashed"</code>
<p>Notice that all eight levels can occur in the heading,
- not only <c>ERROR</c>, <c>WARNING</c> or <c>INFO</c> as the
- old <c>error_logger</c> produced. And microseconds are
- added at the end of the timestamp.</p>
+ not only <c>ERROR</c>, <c>WARNING</c> or <c>INFO</c> as
+ <seealso marker="error_logger"><c>error_logger</c></seealso>
+ produces. And microseconds are added at the end of the
+ timestamp.</p>
</item>
- <tag><c>legacy_header=true, single_line=true</c></tag>
+ <tag><c>legacy_header = true, single_line = true</c></tag>
<item>
<p>Default
- template: <c>[{logger_formatter,header},"\n",msg,"\n"]</c></p>
+ template: <c>[[logger_formatter,header],"\n",msg,"\n"]</c></p>
<p>Notice that the template is here the same as
for <c>single_line=false</c>, but the resulting log entry
@@ -250,7 +259,7 @@ exit_reason: "It crashed"</code>
name: my_name, exit_reason: "It crashed"</code>
</item>
- <tag><c>legacy_header=false, single_line=true</c></tag>
+ <tag><c>legacy_header = false, single_line = true</c></tag>
<item>
<p>Default template: <c>[time," ",level,": ",msg,"\n"]</c></p>
@@ -259,7 +268,7 @@ name: my_name, exit_reason: "It crashed"</code>
2018-05-17T18:31:31.152864+02:00 error: name: my_name, exit_reason: "It crashed"</code>
</item>
- <tag><c>legacy_header=false, single_line=false</c></tag>
+ <tag><c>legacy_header = false, single_line = false</c></tag>
<item>
<p>Default template: <c>[time," ",level,":\n",msg,"\n"]</c></p>
@@ -279,10 +288,21 @@ exit_reason: "It crashed"</code>
<name name="check_config" arity="1"/>
<fsummary>Validates the given formatter configuration.</fsummary>
<desc>
- <p>This callback function is called by Logger when the
- formatter configuration for a handler is set or modified. It
+ <p>The function is called by Logger when the formatter
+ configuration for a handler is set or modified. It
returns <c>ok</c> if the configuration is valid,
and <c>{error,term()}</c> if it is faulty.</p>
+ <p>The following Logger API functions can trigger this callback:</p>
+ <list>
+ <item><seealso marker="logger#add_handler-3">
+ <c>logger:add_handler/3</c></seealso></item>
+ <item><seealso marker="logger#set_handler_config-2">
+ <c>logger:set_handler_config/2,3</c></seealso></item>
+ <item><seealso marker="logger#update_handler_config-2">
+ <c>logger:updata_handler_config/2</c></seealso></item>
+ <item><seealso marker="logger#update_formatter_config-2">
+ <c>logger:update_formatter_config/2</c></seealso></item>
+ </list>
</desc>
</func>
<func>
@@ -293,22 +313,38 @@ exit_reason: "It crashed"</code>
handlers. The log event is processed as follows:</p>
<list>
<item>If the message is on report form, it is converted to
- <c>{Format,Args}</c> by calling the report
- callback.</item>
- <item>The size is limited according to the values of
- configuration parameters <c>chars_limit</c>
- and <c>depth</c>. Notice that this does not apply to
- messages on string form.</item>
+ <c>{Format,Args}</c> by calling the report callback. See
+ section <seealso marker="logger_chapter#log_message">Log
+ Message</seealso> in the Kernel User's Guide for more
+ information about report callbacks and valid forms of log
+ messages.</item>
+ <item>The message size is limited according to the values of
+ configuration parameters <seealso marker="#chars_limit">
+ <c>chars_limit</c></seealso>
+ and <seealso marker="#depth"><c>depth</c></seealso>.</item>
<item>The full log entry is composed according to
- the <c>template</c>.</item>
+ the <seealso marker="#template"><c>template</c></seealso>.</item>
<item>If the final string is too long, it is truncated
according to the value of configuration
- parameter <c>max_size</c>.</item>
+ parameter <seealso marker="#max_size"><c>max_size</c></seealso>.</item>
</list>
</desc>
</func>
</funcs>
+ <section>
+ <title>See Also</title>
+ <p>
+ <seealso marker="stdlib:calendar"><c>calendar(3)</c></seealso>,
+ <seealso marker="error_logger"><c>error_logger(3)</c></seealso>,
+ <seealso marker="stdlib:io"><c>io(3)</c></seealso>,
+ <seealso marker="stdlib:io_lib"><c>io_lib(3)</c></seealso>,
+ <seealso marker="logger"><c>logger(3)</c></seealso>,
+ <seealso marker="stdlib:maps"><c>maps(3)</c></seealso>,
+ <seealso marker="sasl:sasl_app"><c>sasl(6)</c></seealso>,
+ <seealso marker="stdlib:unicode"><c>unicode(3)</c></seealso>
+ </p>
+ </section>
</erlref>
diff --git a/lib/kernel/doc/src/logger_std_h.xml b/lib/kernel/doc/src/logger_std_h.xml
index a4f2848037..89e11389c5 100644
--- a/lib/kernel/doc/src/logger_std_h.xml
+++ b/lib/kernel/doc/src/logger_std_h.xml
@@ -54,7 +54,7 @@
general configuration parameters, as documented in the
<seealso marker="logger_chapter#handler_configuration"><c>User's Guide</c>
</seealso>, as well as handler specific parameters. The specific parameters
- are stored in a sub map with the key <c>logger_std_h</c>. The following
+ are stored in a sub map with the key <c>config</c>. The following
keys and values may be specified:</p>
<taglist>
<tag><marker id="type"/><c>type</c></tag>
@@ -78,7 +78,7 @@
If <c>no_repeat</c> is set as value, the repeated file sync operation
is disabled, and it will be the operating system settings that determine
how quickly or slowly data gets written to disk. The user can also call
- the <seealso marker="logger_std_h#filesync-1"><c>filesync/1</c></seealso>
+ the <seealso marker="logger_std_h#sync-1"><c>sync/1</c></seealso>
function to perform a file sync.</p></item>
</taglist>
<p>There are a number of other configuration parameters available, that are
@@ -99,26 +99,26 @@
logger:add_handler(my_standard_h, logger_std_h,
#{level => info,
filter_default => log,
- logger_std_h =>
- #{type => {file,"./system_info.log"},
- filesync_repeat_interval => 1000}}).
+ config =>
+ #{type => {file,"./system_info.log"},
+ filesync_repeat_interval => 1000}}).
</code>
<p>In order to configure the default handler (that starts initially with
the Kernel application) to log to file instead of <c>standard_io</c>,
change the Kernel default logger to use a file. Example:</p>
<code type="none">
erl -kernel logger '[{handler,default,logger_std_h,
- #{ logger_std_h => #{ type => {file,"./log.log"}}}}]'
+ #{config => #{type => {file,"./log.log"}}}}]'
</code>
<p>An example of how to replace the standard handler with a disk_log handler
- at startup can be found in the manual of
+ at start up can be found in the manual of
<seealso marker="logger_disk_log_h"><c>logger_disk_log_h</c></seealso>.</p>
</description>
<funcs>
<func>
- <name name="filesync" arity="1" clause_i="1"/>
+ <name name="sync" arity="1" clause_i="1"/>
<fsummary>Writes buffered data to disk.</fsummary>
<desc>
<p>Write buffered data to disk.</p>
@@ -129,8 +129,9 @@ erl -kernel logger '[{handler,default,logger_std_h,
<section>
<title>See Also</title>
- <p><seealso marker="logger"><c>logger(3)</c></seealso></p>
- <p><seealso marker="logger_disk_log_h"><c>logger_disk_log_h(3)</c></seealso></p>
+ <p><seealso marker="logger"><c>logger(3)</c></seealso>,
+ <seealso marker="logger_disk_log_h">
+ <c>logger_disk_log_h(3)</c></seealso></p>
</section>
</erlref>
diff --git a/lib/kernel/doc/src/part.xml b/lib/kernel/doc/src/part.xml
index 68eb4530e2..fa7e92835f 100644
--- a/lib/kernel/doc/src/part.xml
+++ b/lib/kernel/doc/src/part.xml
@@ -4,7 +4,7 @@
<part xmlns:xi="http://www.w3.org/2001/XInclude">
<header>
<copyright>
- <year>1996</year><year>2017</year>
+ <year>2018</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -22,17 +22,14 @@
</legalnotice>
- <title>Logger User's Guide</title>
+ <title>Kernel User's Guide</title>
<prepared>OTP Team</prepared>
<docno></docno>
- <date>2017-12-01</date>
- <rev>0.1</rev>
+ <date>2018-06-06</date>
<file>part.xml</file>
</header>
<description>
- <p>The System Architecture Support Libraries SASL application
- provides support for alarm handling, release handling, and
- related functions.</p>
+ <p></p>
</description>
<xi:include href="introduction_chapter.xml"/>
<xi:include href="logger_chapter.xml"/>