diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kernel/doc/src/logger_chapter.xml | 11 | ||||
-rw-r--r-- | lib/kernel/src/logger.erl | 3 | ||||
-rw-r--r-- | lib/kernel/src/logger_formatter.erl | 2 |
3 files changed, 10 insertions, 6 deletions
diff --git a/lib/kernel/doc/src/logger_chapter.xml b/lib/kernel/doc/src/logger_chapter.xml index 26066d0777..4a81cfa34a 100644 --- a/lib/kernel/doc/src/logger_chapter.xml +++ b/lib/kernel/doc/src/logger_chapter.xml @@ -209,10 +209,13 @@ <pre>fun((<seealso marker="logger#type-report"><c>logger:report()</c></seealso>,<seealso marker="logger#type-report_cb_config"><c>logger:report_cb_config()</c></seealso>) -> <seealso marker="stdlib:unicode#type-chardata"><c>unicode:chardata()</c></seealso>) </pre> <p>The fun must obey the <c>depth</c> and <c>chars_limit</c> - parameters provided in the second argument, as the formatter - can not do anything useful of these parameters with the - returned string. This variant is used when the formatting of - the report depends on the size parameters.</p> + parameters provided in the second argument, as the formatter can + not do anything useful of these parameters with the returned + string. The extra data also contains a field named + <c>single_line</c>, indicating if the printed log message may + contain line breaks or not. This variant is used when the + formatting of the report depends on the size or single line + parameters.</p> <p>Example, format string and arguments:</p> <code>logger:error("The file does not exist: ~ts",[Filename])</code> <p>Example, string:</p> 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 _:_ -> |