Kernel

Reference Manual

Version 6.0

Table of Contents

logger_filters

Module

logger_filters

Module Summary

Filters to use with logger.

Description

Filters to use with logger. All functions exported from this module can be used as logger or handler filters. See logger:add_logger_filter/2 and logger:add_handler_filter/3 for more information about how filters are added.

Exports

domain(Log, Extra) -> logger:filter_return()

Types

Extra = {Action, Compare, MatchDomain}
Action = log | stop
Compare = prefix_of | starts_with | equals | no_domain
MatchDomain = [atom()]

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

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

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

Compare = starts_with

The filter matches if MatchDomain is a prefix of Domain.

Compare = prefix_of

The filter matches if Domain is a prefix of MatchDomain.

Compare = equals

The filter matches if Domain is equal to MatchDomain.

Compare = no_domain

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

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

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

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

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

logger:set_handler_config(h1,filter_default,log). % this is the default
Filter = {fun logger_filters:domain/2,{stop,starts_with,[beam,erlang,otp,sasl]}}.
logger:add_handler_filter(h1,no_sasl,Filter).
ok

level(Log, Extra) -> logger:filter_return()

Types

Extra = {Action, Operator, MatchLevel}
Action = log | stop
Operator = neq | eq | lt | gt | lteq | gteq
MatchLevel = logger:level()

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 MatchLevel

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

The filter compares the value of the event's log level (Level) to MatchLevel by calling logger:compare_levels(Level,MatchLevel) -> CmpRet. It matches the event if:

  • CmpRet = eq and Operator = eq | lteq | gteq
  • CmpRet = lt and Operator = lt | lteq | neq
  • CmpRet = gt and Operator = gt | gteq | neq

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

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

Example: only allow debug level log events

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

progress(Log, Extra) -> logger:filter_return()

Types

Extra = log | stop

This filter matches all progress reports from supervisor and application_controller.

If Extra = log, the progress reports are allowed. If Extra = stop, the progress reports are stopped.

The filter returns ignore for all other log events.

remote_gl(Log, Extra) -> logger:filter_return()

Types

Extra = log | stop

This filter matches all events originating from a process that has its group leader on a remote node.

If Extra = log, the matching events are allowed. If Extra = stop, the matching events are stopped.

The filter returns ignore for all other log events.