diff options
author | Siri Hansen <[email protected]> | 2018-05-09 17:22:43 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2018-05-21 17:43:53 +0200 |
commit | bfe8a57bb9356415e6438f0deb410b03a7c602d1 (patch) | |
tree | 2d3ace36d9a0d5858f8c861ff5499e4dc1685431 /lib/kernel | |
parent | 92d93f85e88235f3fa757d300628d382d09c6226 (diff) | |
download | otp-bfe8a57bb9356415e6438f0deb410b03a7c602d1.tar.gz otp-bfe8a57bb9356415e6438f0deb410b03a7c602d1.tar.bz2 otp-bfe8a57bb9356415e6438f0deb410b03a7c602d1.zip |
Remove logger env vars for format_depth, max_size and utc
These are replaced by new config handling and must not be used any
more.
Diffstat (limited to 'lib/kernel')
-rw-r--r-- | lib/kernel/src/error_logger.erl | 8 | ||||
-rw-r--r-- | lib/kernel/src/logger.erl | 60 | ||||
-rw-r--r-- | lib/kernel/src/logger_formatter.erl | 29 | ||||
-rw-r--r-- | lib/kernel/test/logger_formatter_SUITE.erl | 50 |
4 files changed, 51 insertions, 96 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. diff --git a/lib/kernel/test/logger_formatter_SUITE.erl b/lib/kernel/test/logger_formatter_SUITE.erl index c80e5694cf..bd5bc2d2e4 100644 --- a/lib/kernel/test/logger_formatter_SUITE.erl +++ b/lib/kernel/test/logger_formatter_SUITE.erl @@ -297,22 +297,22 @@ max_size(_Config) -> single_line=>false}, "12345678901234567890" = format(info,{"12345678901234567890",[]},#{},Cfg), - application:set_env(kernel,logger_max_size,11), - "12345678901234567890" = % min value is 50, so this is not limited - format(info,{"12345678901234567890",[]},#{},Cfg), - "12345678901234567890123456789012345678901234567..." = % 50 - format(info, - {"123456789012345678901234567890123456789012345678901234567890", - []}, - #{}, - Cfg), - application:set_env(kernel,logger_max_size,53), - "12345678901234567890123456789012345678901234567890..." = %53 - format(info, - {"123456789012345678901234567890123456789012345678901234567890", - []}, - #{}, - Cfg), + %% application:set_env(kernel,logger_max_size,11), + %% "12345678901234567890" = % min value is 50, so this is not limited + %% format(info,{"12345678901234567890",[]},#{},Cfg), + %% "12345678901234567890123456789012345678901234567..." = % 50 + %% format(info, + %% {"123456789012345678901234567890123456789012345678901234567890", + %% []}, + %% #{}, + %% Cfg), + %% application:set_env(kernel,logger_max_size,53), + %% "12345678901234567890123456789012345678901234567890..." = %53 + %% format(info, + %% {"123456789012345678901234567890123456789012345678901234567890", + %% []}, + %% #{}, + %% Cfg), "123456789012..." = format(info,{"12345678901234567890",[]},#{},Cfg#{max_size=>15}), "12345678901234567890" = @@ -341,12 +341,6 @@ depth(_Config) -> {"~p",[[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0]]}, #{}, #{template=>Template}), - application:set_env(kernel,error_logger_format_depth,12), - "[1,2,3,4,5,6,7,8,9,0,1|...]" = - format(info, - {"~p",[[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0]]}, - #{}, - #{template=>Template}), "[1,2,3,4,5,6,7,8,9,0,1,2|...]" = format(info, {"~p",[[1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0]]}, @@ -451,12 +445,12 @@ format_time(_Config) -> ct:log(String2), " info: term\n" = string:prefix(String2,ExpectedTimestamp2), - application:set_env(kernel,logger_utc,true), - Time3 = timestamp(), - ExpectedTimestamp3 = default_time_format(Time3,true), - String3 = format(info,{"~p",[term]},#{time=>Time3},#{}), - ct:log(String3), - " info: term\n" = string:prefix(String3,ExpectedTimestamp3), + %% application:set_env(kernel,logger_utc,true), + %% Time3 = timestamp(), + %% ExpectedTimestamp3 = default_time_format(Time3,true), + %% String3 = format(info,{"~p",[term]},#{time=>Time3},#{}), + %% ct:log(String3), + %% " info: term\n" = string:prefix(String3,ExpectedTimestamp3), ok. |