aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2019-01-10 15:03:54 +0100
committerSiri Hansen <[email protected]>2019-01-16 09:59:24 +0100
commitb387ef2366f92417bcec81e461539844750fc18a (patch)
tree3305e6ad506f08131b71d32c70244c305656cc51
parent06b9756aceb200c359015a088f86e8afc097dc97 (diff)
downloadotp-b387ef2366f92417bcec81e461539844750fc18a.tar.gz
otp-b387ef2366f92417bcec81e461539844750fc18a.tar.bz2
otp-b387ef2366f92417bcec81e461539844750fc18a.zip
[logger] Log mode change and flushes in logger_proxy
-rw-r--r--lib/kernel/src/logger_internal.hrl8
-rw-r--r--lib/kernel/src/logger_proxy.erl18
2 files changed, 19 insertions, 7 deletions
diff --git a/lib/kernel/src/logger_internal.hrl b/lib/kernel/src/logger_internal.hrl
index d96a4ac78b..318fe6b037 100644
--- a/lib/kernel/src/logger_internal.hrl
+++ b/lib/kernel/src/logger_internal.hrl
@@ -40,12 +40,14 @@
-define(DEFAULT_LOGGER_CALL_TIMEOUT, infinity).
--define(LOG_INTERNAL(Level,Report),
+-define(LOG_INTERNAL(Level,Report),?DO_LOG_INTERNAL(Level,[Report])).
+-define(LOG_INTERNAL(Level,Format,Args),?DO_LOG_INTERNAL(Level,[Format,Args])).
+-define(DO_LOG_INTERNAL(Level,Data),
case logger:allow(Level,?MODULE) of
true ->
%% Spawn this to avoid deadlocks
- _ = spawn(logger,macro_log,[?LOCATION,Level,Report,
- logger:add_default_metadata(#{})]),
+ _ = spawn(logger,macro_log,[?LOCATION,Level|Data]++
+ [logger:add_default_metadata(#{})]),
ok;
false ->
ok
diff --git a/lib/kernel/src/logger_proxy.erl b/lib/kernel/src/logger_proxy.erl
index a72952df2f..8ac86f17e9 100644
--- a/lib/kernel/src/logger_proxy.erl
+++ b/lib/kernel/src/logger_proxy.erl
@@ -135,11 +135,21 @@ terminate(_Reason, _State) ->
_ = erlang:system_flag(system_logger,whereis(logger)),
ok.
-notify({mode_change,_Mode0,drop},State) ->
- _ = erlang:system_flag(system_logger,undefined),
+notify({mode_change,Mode0,Mode1},State) ->
+ _ = if Mode1=:=drop -> % entering drop mode
+ erlang:system_flag(system_logger,undefined);
+ Mode0=:=drop -> % leaving drop mode
+ erlang:system_flag(system_logger,self());
+ true ->
+ ok
+ end,
+ ?LOG_INTERNAL(notice,"~w switched from ~w to ~w mode",[?MODULE,Mode0,Mode1]),
State;
-notify({mode_change,drop,_Mode1},State) ->
- _ = erlang:system_flag(system_logger,self()),
+notify({flushed,Flushed},State) ->
+ ?LOG_INTERNAL(notice, "~w flushed ~w log events",[?MODULE,Flushed]),
+ State;
+notify(restart,State) ->
+ ?LOG_INTERNAL(notice, "~w restarted", [?MODULE]),
State;
notify(_Note,State) ->
State.