Procházet zdrojové kódy

Correct printing of strings in mixed error reports (reported by Bryan Hughes)

Since the lager_format rewrite, ~p and ~w now have different behaviour
with regard to printing lists as strings.
pull/28/head
Andrew Thompson před 13 roky
rodič
revize
16fb55890c
2 změnil soubory, kde provedl 11 přidání a 3 odebrání
  1. +2
    -2
      src/error_logger_lager_h.erl
  2. +9
    -1
      test/lager_test_backend.erl

+ 2
- 2
src/error_logger_lager_h.erl Zobrazit soubor

@ -266,9 +266,9 @@ print_silly_list([], Fmt, Acc) ->
lager_trunc_io:format(string:join(lists:reverse(Fmt), ", "),
lists:reverse(Acc), 4096);
print_silly_list([{K,V}|T], Fmt, Acc) ->
print_silly_list(T, ["~w: ~w" | Fmt], [V, K | Acc]);
print_silly_list(T, ["~p: ~p" | Fmt], [V, K | Acc]);
print_silly_list([H|T], Fmt, Acc) ->
print_silly_list(T, ["~w" | Fmt], [H | Acc]).
print_silly_list(T, ["~p" | Fmt], [H | Acc]).
print_val(Val) ->
{Str, _} = lager_trunc_io:print(Val, 500),

+ 9
- 1
test/lager_test_backend.erl Zobrazit soubor

@ -509,7 +509,15 @@ error_logger_redirect_test_() ->
?assert(length(lists:flatten(Msg)) < 5100)
end
},
{"strings in a mixed report are printed as strings",
fun() ->
sync_error_logger:info_report(["this is less silly", {than, "this"}]),
_ = gen_event:which_handlers(error_logger),
{_, _, Msg} = pop(),
Expected = lists:flatten(io_lib:format("[info] ~w \"this is less silly\", than: \"this\"", [self()])),
?assertEqual(Expected, lists:flatten(Msg))
end
},
{"info messages are printed",
fun() ->
sync_error_logger:info_msg("doom, doom has come upon you all"),

Načítá se…
Zrušit
Uložit