From 9692bb3126332160cc4eda1f24163f88f5a57672 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Tue, 22 Aug 2017 11:55:39 +0200 Subject: stdlib: use Unicode translation modifier in error_logger_file_h Since error_logger_file_h now opens its log file with encoding utf8, it is ok to print with the 't' modifier in format strings. --- lib/stdlib/src/error_logger_file_h.erl | 36 +++++++++------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/src/error_logger_file_h.erl b/lib/stdlib/src/error_logger_file_h.erl index b7c193f965..58da0cbdd6 100644 --- a/lib/stdlib/src/error_logger_file_h.erl +++ b/lib/stdlib/src/error_logger_file_h.erl @@ -126,7 +126,7 @@ format_body(State, [{Format,Args}|T]) -> S0 catch _:_ -> - format(State, "ERROR: ~p - ~p\n", [Format,Args]) + format(State, "ERROR: ~tp - ~tp\n", [Format,Args]) end, [S|format_body(State, T)]; format_body(_State, []) -> @@ -165,44 +165,26 @@ parse_event({warning_report, _GL, {Pid, std_warning, Args}}) -> parse_event(_) -> ignore. format_term(Term) when is_list(Term) -> - case string_p(Term) of + case string_p(lists:flatten(Term)) of true -> - [{"~s\n",[Term]}]; + [{"~ts\n",[Term]}]; false -> format_term_list(Term) end; format_term(Term) -> - [{"~p\n",[Term]}]. + [{"~tp\n",[Term]}]. format_term_list([{Tag,Data}|T]) -> - [{" ~p: ~p\n",[Tag,Data]}|format_term_list(T)]; + [{" ~tp: ~tp\n",[Tag,Data]}|format_term_list(T)]; format_term_list([Data|T]) -> - [{" ~p\n",[Data]}|format_term_list(T)]; + [{" ~tp\n",[Data]}|format_term_list(T)]; format_term_list([]) -> - []; -format_term_list(_) -> - %% Continue to allow non-proper lists for now. - %% FIXME: Remove this clause in OTP 19. []. string_p([]) -> false; -string_p(Term) -> - string_p1(Term). - -string_p1([H|T]) when is_integer(H), H >= $\s, H < 255 -> - string_p1(T); -string_p1([$\n|T]) -> string_p1(T); -string_p1([$\r|T]) -> string_p1(T); -string_p1([$\t|T]) -> string_p1(T); -string_p1([$\v|T]) -> string_p1(T); -string_p1([$\b|T]) -> string_p1(T); -string_p1([$\f|T]) -> string_p1(T); -string_p1([$\e|T]) -> string_p1(T); -string_p1([H|T]) when is_list(H) -> - string_p1(H) andalso string_p1(T); -string_p1([]) -> true; -string_p1(_) -> false. +string_p(FlatList) -> + io_lib:printable_list(FlatList). get_utc_config() -> %% SASL utc_log configuration overrides stdlib config @@ -225,7 +207,7 @@ header(Time, Title) -> end. header({{Y,Mo,D},{H,Mi,S}}, Title, UTC) -> - io_lib:format("~n=~s==== ~p-~s-~p::~s:~s:~s ~s===~n", + io_lib:format("~n=~ts==== ~p-~s-~p::~s:~s:~s ~s===~n", [Title,D,month(Mo),Y,t(H),t(Mi),t(S),UTC]). t(X) when is_integer(X) -> -- cgit v1.2.3