aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kernel/src')
-rw-r--r--lib/kernel/src/error_logger.erl8
-rw-r--r--lib/kernel/src/logger.erl60
-rw-r--r--lib/kernel/src/logger_formatter.erl29
3 files changed, 29 insertions, 68 deletions
diff --git a/lib/kernel/src/error_logger.erl b/lib/kernel/src/error_logger.erl
index 47d0ca5ea3..196c70d05f 100644
--- a/lib/kernel/src/error_logger.erl
+++ b/lib/kernel/src/error_logger.erl
@@ -540,7 +540,6 @@ tty(false) ->
delete_report_handler(error_logger_tty_h).
%%%-----------------------------------------------------------------
-
-spec limit_term(term()) -> term().
limit_term(Term) ->
@@ -552,4 +551,9 @@ limit_term(Term) ->
-spec get_format_depth() -> 'unlimited' | pos_integer().
get_format_depth() ->
- logger:get_format_depth().
+ case application:get_env(kernel, error_logger_format_depth) of
+ {ok, Depth} when is_integer(Depth) ->
+ max(10, Depth);
+ undefined ->
+ unlimited
+ end.
diff --git a/lib/kernel/src/logger.erl b/lib/kernel/src/logger.erl
index 9a6719923e..7ce4a80bbd 100644
--- a/lib/kernel/src/logger.erl
+++ b/lib/kernel/src/logger.erl
@@ -51,7 +51,6 @@
-export([set_process_metadata/1, update_process_metadata/1,
unset_process_metadata/0, get_process_metadata/0]).
-export([i/0, i/1]).
--export([limit_term/1, get_format_depth/0, get_max_size/0, get_utc_config/0]).
%% Basic report formatting
-export([format_report/1, format_otp_report/1]).
@@ -706,65 +705,6 @@ get_logger_env() ->
application:get_env(kernel, logger, []).
%%%-----------------------------------------------------------------
--spec limit_term(term()) -> term().
-
-limit_term(Term) ->
- try get_format_depth() of
- unlimited -> Term;
- D -> io_lib:limit_term(Term, D)
- catch error:badarg ->
- %% This could happen during system termination, after
- %% application_controller process is dead.
- unlimited
- end.
-
--spec get_format_depth() -> 'unlimited' | pos_integer().
-
-get_format_depth() ->
- Depth =
- case application:get_env(kernel, logger_format_depth) of
- {ok, D} when is_integer(D) ->
- D;
- undefined ->
- case application:get_env(kernel, error_logger_format_depth) of
- {ok, D} when is_integer(D) ->
- D;
- undefined ->
- unlimited
- end
- end,
- max(10, Depth).
-
--spec get_max_size() -> 'unlimited' | pos_integer().
-
-get_max_size() ->
- case application:get_env(kernel, logger_max_size) of
- {ok, Size} when is_integer(Size) ->
- max(50, Size);
- undefined ->
- unlimited
- end.
-
--spec get_utc_config() -> boolean().
-
-get_utc_config() ->
- %% Kernel's logger_utc configuration overrides SASL utc_log, which
- %% in turn overrides stdlib config - in order to have uniform
- %% timestamps in log messages
- case application:get_env(kernel, logger_utc) of
- {ok, Val} -> Val;
- undefined ->
- case application:get_env(sasl, utc_log) of
- {ok, Val} -> Val;
- undefined ->
- case application:get_env(stdlib, utc_log) of
- {ok, Val} -> Val;
- undefined -> false
- end
- end
- end.
-
-%%%-----------------------------------------------------------------
%%% Internal
do_log(warning,Msg,Meta) ->
do_log_1(error_logger:warning_map(),Msg,Meta);
diff --git a/lib/kernel/src/logger_formatter.erl b/lib/kernel/src/logger_formatter.erl
index 8e954f8d98..624f523465 100644
--- a/lib/kernel/src/logger_formatter.erl
+++ b/lib/kernel/src/logger_formatter.erl
@@ -259,17 +259,17 @@ month(12) -> "Dec".
utcstr(#{utc:=true}) -> "UTC ";
utcstr(_) -> "".
-add_default_config(#{utc:=_}=Config0) ->
+add_default_config(Config0) ->
Default =
#{legacy_header=>false,
single_line=>true,
chars_limit=>unlimited},
MaxSize = get_max_size(maps:get(max_size,Config0,false)),
Depth = get_depth(maps:get(depth,Config0,false)),
+ Utc = get_utc(maps:get(utc,Config0,false)),
add_default_template(maps:merge(Default,Config0#{max_size=>MaxSize,
- depth=>Depth}));
-add_default_config(Config) ->
- add_default_config(Config#{utc=>logger:get_utc_config()}).
+ depth=>Depth,
+ utc=>Utc})).
add_default_template(#{template:=_}=Config) ->
Config;
@@ -284,11 +284,28 @@ default_template(_) ->
?DEFAULT_FORMAT_TEMPLATE.
get_max_size(false) ->
- logger:get_max_size();
+ unlimited;
get_max_size(S) ->
max(10,S).
get_depth(false) ->
- logger:get_format_depth();
+ error_logger:get_format_depth();
get_depth(S) ->
max(5,S).
+
+get_utc(false) ->
+ get_utc_config();
+get_utc(U) ->
+ U.
+
+get_utc_config() ->
+ %% SASL utc_log overrides stdlib config - in order to have uniform
+ %% timestamps in log messages
+ case application:get_env(sasl, utc_log) of
+ {ok, Val} -> Val;
+ undefined ->
+ case application:get_env(stdlib, utc_log) of
+ {ok, Val} -> Val;
+ undefined -> false
+ end
+ end.