diff options
author | Siri Hansen <[email protected]> | 2018-09-12 14:37:02 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2018-09-12 14:58:02 +0200 |
commit | a4ff9f378ae7008e268d1c2facd44d049be6e930 (patch) | |
tree | 8720a85fd958a7fe4670f2ff0b52f246fd719235 /lib/kernel/src | |
parent | 7140fe7679c1ea0862961d2fc34f9d8283c04ca3 (diff) | |
download | otp-a4ff9f378ae7008e268d1c2facd44d049be6e930.tar.gz otp-a4ff9f378ae7008e268d1c2facd44d049be6e930.tar.bz2 otp-a4ff9f378ae7008e268d1c2facd44d049be6e930.zip |
[logger] Include single_line option to report_cb
If the report callback function has two arguments, the second argument
is a map with options to limit the size of the log event. To even
allow a better formatting when the event shall be printed on a single
line, the new option single_line is now included in this
argument.
Diffstat (limited to 'lib/kernel/src')
-rw-r--r-- | lib/kernel/src/logger.erl | 3 | ||||
-rw-r--r-- | lib/kernel/src/logger_formatter.erl | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/kernel/src/logger.erl b/lib/kernel/src/logger.erl index 0ada8b4924..752dd8d493 100644 --- a/lib/kernel/src/logger.erl +++ b/lib/kernel/src/logger.erl @@ -78,7 +78,8 @@ -type report_cb() :: fun((report()) -> {io:format(),[term()]}) | fun((report(),report_cb_config()) -> unicode:chardata()). -type report_cb_config() :: #{depth := pos_integer() | unlimited, - chars_limit := pos_integer() | unlimited}. + chars_limit := pos_integer() | unlimited, + single_line := boolean()}. -type msg_fun() :: fun((term()) -> {io:format(),[term()]} | report() | unicode:chardata()). diff --git a/lib/kernel/src/logger_formatter.erl b/lib/kernel/src/logger_formatter.erl index 59aa6ec3af..ded89bac9f 100644 --- a/lib/kernel/src/logger_formatter.erl +++ b/lib/kernel/src/logger_formatter.erl @@ -165,7 +165,7 @@ format_msg({report,Report},#{report_cb:=Fun}=Meta,Config) when is_function(Fun,1 Meta,Config) end; format_msg({report,Report},#{report_cb:=Fun}=Meta,Config) when is_function(Fun,2) -> - try Fun(Report,maps:with([depth,chars_limit],Config)) of + try Fun(Report,maps:with([depth,chars_limit,single_line],Config)) of Chardata when ?IS_STRING(Chardata) -> try chardata_to_list(Chardata) % already size limited by report_cb catch _:_ -> |