Module logi_condition

Sink Applicable Condition.

Copyright © 2014-2016 Takeru Ohta <phjgt308@gmail.com>

Description

Sink Applicable Condition

Data Types

condition()

condition() = severity_condition() | location_condition()

The condition to determine which messages to be consumed by a sink.

location_condition()

location_condition() = #{severity => severity_condition(), application => logi_location:application() | [logi_location:application()], module => module() | [module()]}

The messages which satisfy severity (default is debug) and are sent from the specified location will be consumed.

The location is specified by application and module (OR condition).

NOTE: The modules which does not belong to any application are forbidden.

EXAMPLE

  > logi_condition:is_condition(#{application => stdlib}).                          % application
  > logi_condition:is_condition(#{application => [stdlib, kernel]}).                % applications
  > logi_condition:is_condition(#{module => lists}).                                % module
  > logi_condition:is_condition(#{module => [lists, dict]}).                        % modules
  > logi_condition:is_condition(#{application => kernel, module => [lists, dict]}). % application and modules
  > logi_condition:is_condition(#{severity => [info, alert], module => lists}).     % severity and module
  

normalized_condition()

normalized_condition() = [logi:severity() | {logi:severity(), logi_location:application()} | {logi:severity(), logi_location:application(), module()}]

The normalized form of a condition/0.

  > Normalize = fun (C) -> lists:sort(logi_condition:normalize(C)) end.
 
  > Normalize(info).
  [alert,critical,emergency,error,info,notice,warning]
 
  > Normalize({info, alert}).
  [alert,critical,error,info,notice,warning]
 
  > Normalize(#{severity => [info], application => [kernel, stdlib]}).
  [{info,kernel},{info,stdlib}]
 
  > Normalize(#{severity => [info], module => [lists, logi]}).
  [{info,logi,logi},{info,stdlib,lists}]
 
  > Normalize(#{severity => [info], application => kernel, module => [lists, logi]}).
  [{info,kernel},{info,logi,logi},{info,stdlib,lists}]
  

severity_condition()

severity_condition() = (Min::logi:severity()) | {Min::logi:severity(), Max::logi:severity()} | (Severities::[logi:severity()])

Min: - The messages with Min or higher severity will be consumed.

{Min, Max}: - The messages with severity between Min and Max will be consumed.

Severities: - The messages with severity included in Severities will be consumed.

EXAMPLE

  > [emergency,alert]     = logi_condition:normalize(alert).                % level
  > [warning,notice,info] = logi_condition:normalize({info, warning}).      % range
  > [alert,debug,info]    = logi_condition:normalize([debug, info, alert]). % list
  

Function Index

is_condition/1Returns true if X is a valid condition() value, otherwise false
normalize/1Returns a normalized form of Condition

Function Details

is_condition/1

is_condition(X::condition() | term()) -> boolean()

Returns true if X is a valid condition() value, otherwise false

normalize/1

normalize(Condition::condition()) -> normalized_condition()

Returns a normalized form of Condition


Generated by EDoc