From 6211cead7be6f0871cfcccccdfc00dbeb466bcf2 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 14 Dec 2018 13:05:32 +0100 Subject: [logger] Add API function for configuring logger proxy --- lib/kernel/doc/src/logger.xml | 61 +++++++++++++++++++++++++++++++++-- lib/kernel/doc/src/logger_chapter.xml | 55 +++++++++++++++++++++++++++++-- 2 files changed, 112 insertions(+), 4 deletions(-) (limited to 'lib/kernel/doc') diff --git a/lib/kernel/doc/src/logger.xml b/lib/kernel/doc/src/logger.xml index e09c5db5e3..0668676096 100644 --- a/lib/kernel/doc/src/logger.xml +++ b/lib/kernel/doc/src/logger.xml @@ -244,6 +244,12 @@ logger:error("error happened because: ~p", [Reason]). % Without macro

+ + + +

+
+
@@ -597,8 +603,8 @@ start(_, []) -> Look up the current Logger configuration -

Look up all current Logger configuration, including primary - and handler configuration, and module level settings.

+

Look up all current Logger configuration, including primary, + handler, and proxy configuration, and module level settings.

@@ -635,6 +641,17 @@ start(_, []) ->
+ + + Look up the current configuration for the Logger proxy. + +

Look up the current configuration for the Logger proxy.

+

For more information about the proxy, see + section Logger + Proxy in the Kernel User's Guide.

+
+
+ Look up all current module levels. @@ -800,6 +817,27 @@ start(_, []) -> + + + Set configuration data for the Logger proxy. + +

Set configuration data for the Logger proxy. This + overwrites the current proxy configuration. Keys that are not + specified in the Config map gets default + values.

+

To modify the existing configuration, + use + update_proxy_config/1, or, if a more + complex merge is needed, read the current configuration + with get_proxy_config/0 + , then do the merge before writing the new + configuration back with this function.

+

For more information about the proxy, see + section Logger + Proxy in the Kernel User's Guide.

+
+
+ Set the log level for the specified modules. @@ -1013,6 +1051,25 @@ logger:set_process_metadata(maps:merge(logger:get_process_metadata(), Meta)). .

+ + + + Update configuration data for the Logger proxy. + +

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

+ +Old = logger:get_proxy_config(), +logger:set_proxy_config(maps:merge(Old, Config)). + +

To overwrite the existing configuration without any merge, + use set_proxy_config/1 + .

+

For more information about the proxy, see + section Logger + Proxy in the Kernel User's Guide.

+
+
diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml index 458e61cef5..5ed7397135 100644 --- a/lib/kernel/doc/src/logger_chapter.xml +++ b/lib/kernel/doc/src/logger_chapter.xml @@ -693,8 +693,10 @@ logger:debug(#{got => connection_request, id => Id, state => State}, with logger_sasl_compatible.

With this parameter, you can modify or disable the default - handler, add custom handlers and primary logger filters, and - set log levels per module.

+ handler, add custom handlers and primary logger filters, set + log levels per module, and modify + the proxy + configuration.

Config is any (zero or more) of the following:

{handler, default, undefined} @@ -746,6 +748,14 @@ logger:debug(#{got => connection_request, id => Id, state => State},

for each Module.

Multiple entries of this type are allowed.

+ {proxy, ProxyConfig} + +

Sets the proxy configuration, equivalent to calling

+

+		logger:set_proxy_config(ProxyConfig)
+	    
+

Only one entry of this type is allowed.

+

See section Configuration @@ -1333,10 +1343,51 @@ logger:add_handler(my_disk_log_h, logger_disk_log_h,

+
+ + Logger Proxy +

The Logger proxy is an Erlang process which is part of the + Kernel application's supervision tree. During startup, the proxy + process registers itself as the system_logger, meaning + that log events produced by the emulator are sent to this + process.

+

When a log event is issued on a process which has its group + leader on a remote node, Logger automatically forwards the log + event to the group leader's node. To achieve this, it first + sends the log event as an Erlang message from the original + client process to the proxy on the local node, and the proxy in + turn forwards the event to the proxy on the remote node.

+

When receiving a log event, either from the emulator or from a + remote node, the proxy calls the Logger API to log the event.

+

The proxy process is overload protected in the same way as + described in + section Protecting the + Handler from Overload, but with the following default + values:

+ + #{sync_mode_qlen => 500, + drop_mode_qlen => 1000, + flush_qlen => 5000, + burst_limit_enable => false, + overload_kill_enable => false} +

For log events from the emulator, synchronous message passing + mode is not applicable, since all messages are passed + asynchronously by the emulator. Drop mode is achieved by setting + the system_logger to undefined, forcing the + emulator to drop events until it is set back to the proxy pid + again.

+

The proxy uses + erlang:send_nosuspend/2 when sending log + events to a remote node. If the message could not be sent + without suspending the sender, it is dropped. This is to avoid + blocking the proxy process.

+
+
See Also

disk_log(3), + erlang(3), error_logger(3), logger(3), logger_disk_log_h(3), -- cgit v1.2.3