aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2018-06-04 19:53:02 +0200
committerSiri Hansen <[email protected]>2018-06-08 14:41:34 +0200
commit983a945b84e15f58c3205c37b7bfcad18537325c (patch)
treea1fdce539da80b497bffe3a2c5cba868cb6755d8 /lib/kernel/src
parente5bbcfd47088162a1c349eeb5aa3c37d8263d274 (diff)
downloadotp-983a945b84e15f58c3205c37b7bfcad18537325c.tar.gz
otp-983a945b84e15f58c3205c37b7bfcad18537325c.tar.bz2
otp-983a945b84e15f58c3205c37b7bfcad18537325c.zip
[logger] Add configurable log levels 'all' and 'none'
New default for handlers is 'all'.
Diffstat (limited to 'lib/kernel/src')
-rw-r--r--lib/kernel/src/logger.erl12
-rw-r--r--lib/kernel/src/logger_config.erl8
-rw-r--r--lib/kernel/src/logger_internal.hrl8
-rw-r--r--lib/kernel/src/logger_server.erl2
4 files changed, 19 insertions, 11 deletions
diff --git a/lib/kernel/src/logger.erl b/lib/kernel/src/logger.erl
index 395ec448ff..f18f101930 100644
--- a/lib/kernel/src/logger.erl
+++ b/lib/kernel/src/logger.erl
@@ -96,7 +96,7 @@
-type filter_arg() :: term().
-type filter_return() :: stop | ignore | log_event().
-type config() :: #{id => handler_id(),
- level => level(),
+ level => level() | all | none,
filter_default => log | stop,
filters => [{filter_id(),filter()}],
formatter => {module(),formatter_config()},
@@ -412,7 +412,7 @@ update_formatter_config(HandlerId,Key,Value) ->
-spec set_module_level(Modules,Level) -> ok | {error,term()} when
Modules :: [module()] | module(),
- Level :: level().
+ Level :: level() | all | none.
set_module_level(Module,Level) when is_atom(Module) ->
set_module_level([Module],Level);
set_module_level(Modules,Level) ->
@@ -432,7 +432,7 @@ unset_module_level() ->
-spec get_module_level(Modules) -> [{Module,Level}] when
Modules :: [Module] | Module,
Module :: module(),
- Level :: level().
+ Level :: level() | all | none.
get_module_level(Module) when is_atom(Module) ->
get_module_level([Module]);
get_module_level(Modules) when is_list(Modules) ->
@@ -441,7 +441,7 @@ get_module_level(Modules) when is_list(Modules) ->
-spec get_module_level() -> [{Module,Level}] when
Module :: module(),
- Level :: level().
+ Level :: level() | all | none.
get_module_level() ->
logger_config:get_module_level(?LOGGER_TABLE).
@@ -494,13 +494,13 @@ unset_process_metadata() ->
-spec i() -> #{logger=>config(),
handlers=>[{handler_id(),module(),config()}],
- module_levels=>[{module(),level()}]}.
+ module_levels=>[{module(),level() | all | none}]}.
i() ->
i(term).
-spec i(term) -> #{logger=>config(),
handlers=>[{handler_id(),module(),config()}],
- module_levels=>[{module(),level()}]};
+ module_levels=>[{module(),level() | all | none}]};
(print) -> ok;
(string) -> iolist().
i(_Action = print) ->
diff --git a/lib/kernel/src/logger_config.erl b/lib/kernel/src/logger_config.erl
index 8d05648109..113c8140cf 100644
--- a/lib/kernel/src/logger_config.erl
+++ b/lib/kernel/src/logger_config.erl
@@ -136,6 +136,7 @@ get(Tid) ->
Modules = get_module_level(Tid),
{Logger,Handlers,Modules}.
+level_to_int(none) -> ?LOG_NONE;
level_to_int(emergency) -> ?EMERGENCY;
level_to_int(alert) -> ?ALERT;
level_to_int(critical) -> ?CRITICAL;
@@ -143,8 +144,10 @@ level_to_int(error) -> ?ERROR;
level_to_int(warning) -> ?WARNING;
level_to_int(notice) -> ?NOTICE;
level_to_int(info) -> ?INFO;
-level_to_int(debug) -> ?DEBUG.
+level_to_int(debug) -> ?DEBUG;
+level_to_int(all) -> ?LOG_ALL.
+int_to_level(?LOG_NONE) -> none;
int_to_level(?EMERGENCY) -> emergency;
int_to_level(?ALERT) -> alert;
int_to_level(?CRITICAL) -> critical;
@@ -152,7 +155,8 @@ int_to_level(?ERROR) -> error;
int_to_level(?WARNING) -> warning;
int_to_level(?NOTICE) -> notice;
int_to_level(?INFO) -> info;
-int_to_level(?DEBUG) -> debug.
+int_to_level(?DEBUG) -> debug;
+int_to_level(?LOG_ALL) -> all.
%%%-----------------------------------------------------------------
%%% Internal
diff --git a/lib/kernel/src/logger_internal.hrl b/lib/kernel/src/logger_internal.hrl
index 1325e38f74..a6648d2b2c 100644
--- a/lib/kernel/src/logger_internal.hrl
+++ b/lib/kernel/src/logger_internal.hrl
@@ -54,14 +54,17 @@
%%%-----------------------------------------------------------------
%%% Levels
%%% Using same as syslog
--define(LEVELS,[emergency,
+-define(LEVELS,[none,
+ emergency,
alert,
critical,
error,
warning,
notice,
info,
- debug]).
+ debug,
+ all]).
+-define(LOG_NONE,-1).
-define(EMERGENCY,0).
-define(ALERT,1).
-define(CRITICAL,2).
@@ -70,6 +73,7 @@
-define(NOTICE,5).
-define(INFO,6).
-define(DEBUG,7).
+-define(LOG_ALL,10).
-define(IS_LEVEL(L),
(L=:=emergency orelse
diff --git a/lib/kernel/src/logger_server.erl b/lib/kernel/src/logger_server.erl
index 164e193fa0..adbb2bc009 100644
--- a/lib/kernel/src/logger_server.erl
+++ b/lib/kernel/src/logger_server.erl
@@ -361,7 +361,7 @@ default_config(logger) ->
filter_default=>log};
default_config(Id) ->
#{id=>Id,
- level=>debug,
+ level=>all,
filters=>[],
filter_default=>log,
formatter=>{?DEFAULT_FORMATTER,#{}}}.