Pārlūkot izejas kodu

Rename trunc_io to lager_trunc_io to prevent clashes

pull/4/head
Andrew Thompson pirms 14 gadiem
vecāks
revīzija
4ac01374fa
5 mainītis faili ar 16 papildinājumiem un 12 dzēšanām
  1. +2
    -2
      src/error_logger_lager_h.erl
  2. +5
    -5
      src/lager_crash_log.erl
  3. +3
    -3
      src/lager_stdlib.erl
  4. +5
    -1
      src/lager_trunc_io.erl
  5. +1
    -1
      test/trunc_io_eqc.erl

+ 2
- 2
src/error_logger_lager_h.erl Parādīt failu

@ -188,7 +188,7 @@ format_reason({system_limit, [{M, F, _}|_] = Trace}) ->
{erlang, list_to_atom} ->
"tried to create an atom larger than 255, or maximum atom count exceeded";
_ ->
{Str, _} = trunc_io:print(Trace, 500),
{Str, _} = lager_trunc_io:print(Trace, 500),
Str
end,
["system limit: ", Limit];
@ -208,7 +208,7 @@ format_reason({noproc, MFA}) ->
format_reason({{badfun, Term}, [MFA|_]}) ->
[io_lib:format("bad function ~w in ", [Term]), format_mfa(MFA)];
format_reason(Reason) ->
{Str, _} = trunc_io:print(Reason, 500),
{Str, _} = lager_trunc_io:print(Reason, 500),
Str.
format_mfa({M, F, A}) when is_list(A) ->

+ 5
- 5
src/lager_crash_log.erl Parādīt failu

@ -128,10 +128,10 @@ code_change(_OldVsn, State, _Extra) ->
%% to limit the formatted string's size.
limited_fmt(Fmt, Args, FmtMaxBytes) ->
trunc_io:format(Fmt, Args, FmtMaxBytes).
lager_trunc_io:format(Fmt, Args, FmtMaxBytes).
limited_str(Term, FmtMaxBytes) ->
{Str, _} = trunc_io:print(Term, FmtMaxBytes),
{Str, _} = lager_trunc_io:print(Term, FmtMaxBytes),
Str.
other_node_suffix(Pid) when node(Pid) =/= node() ->
@ -172,12 +172,12 @@ sasl_limited_str(supervisor_report, Report, FmtMaxBytes) ->
Offender = lager_stdlib:sup_get(offender, Report),
FmtString = " Supervisor: ~p~n Context: ~p~n Reason: "
"~s~n Offender: ~s~n~n",
{ReasonStr, _} = trunc_io:print(Reason, FmtMaxBytes),
{OffenderStr, _} = trunc_io:print(Offender, FmtMaxBytes),
{ReasonStr, _} = lager_trunc_io:print(Reason, FmtMaxBytes),
{OffenderStr, _} = lager_trunc_io:print(Offender, FmtMaxBytes),
io_lib:format(FmtString, [Name, Context, ReasonStr, OffenderStr]);
sasl_limited_str(progress, Report, FmtMaxBytes) ->
[begin
{Str, _} = trunc_io:print(Data, FmtMaxBytes),
{Str, _} = lager_trunc_io:print(Data, FmtMaxBytes),
io_lib:format(" ~16w: ~s~n", [Tag, Str])
end || {Tag, Data} <- Report];
sasl_limited_str(crash_report, Report, FmtMaxBytes) ->

+ 3
- 3
src/lager_stdlib.erl Parādīt failu

@ -153,7 +153,7 @@ proc_lib_format([OwnReport,LinkReport], FmtMaxBytes) ->
format_report(Rep, FmtMaxBytes) when is_list(Rep) ->
format_rep(Rep, FmtMaxBytes);
format_report(Rep, FmtMaxBytes) ->
{Str, _} = trunc_io:print(Rep, FmtMaxBytes),
{Str, _} = lager_trunc_io:print(Rep, FmtMaxBytes),
io_lib:format("~p~n", [Str]).
format_rep([{initial_call,InitialCall}|Rep], FmtMaxBytes) ->
@ -185,12 +185,12 @@ format_mfa({M,F,Args}=StartF, FmtMaxBytes) ->
pp_fun(FmtMaxBytes) ->
fun(Term, _I) ->
{Str, _} = trunc_io:print(Term, FmtMaxBytes),
{Str, _} = lager_trunc_io:print(Term, FmtMaxBytes),
io_lib:format("~s", [Str])
end.
format_tag(Tag, Data, FmtMaxBytes) ->
{Str, _} = trunc_io:print(Data, FmtMaxBytes),
{Str, _} = lager_trunc_io:print(Data, FmtMaxBytes),
io_lib:format(" ~p: ~s~n", [Tag, Str]).
%% From OTP stdlib's lib.erl ... These functions aren't exported.

src/trunc_io.erl → src/lager_trunc_io.erl Parādīt failu

@ -25,8 +25,12 @@
%%
%% Source license: Erlang Public License.
%% Original author: Matthias Lang, <tt>matthias@corelatus.se</tt>
%%
%% Various changes to this module, most notably the format/3 implementation
%% were added by Andrew Thompson <andrew@basho.com>. The module has been renamed
%% to avoid conflicts with the vanilla module.
-module(trunc_io).
-module(lager_trunc_io).
-author('matthias@corelatus.se').
%% And thanks to Chris Newcombe for a bug fix
-export([format/3, print/2, fprint/2, safe/2]). % interface functions

+ 1
- 1
test/trunc_io_eqc.erl Parādīt failu

@ -142,7 +142,7 @@ prop_format() ->
FudgeLen = 50, %% trunc_io does not correctly calc safe size of pid/port/numbers/funs
{FmtStr, Args} = build_fmt_args(FmtArgs),
try
Str = lists:flatten(trunc_io:format(FmtStr, Args, MaxLen)),
Str = lists:flatten(lager_trunc_io:format(FmtStr, Args, MaxLen)),
?WHENFAIL(begin
io:format(user, "FmtStr: ~p\n", [FmtStr]),
io:format(user, "Args: ~p\n", [Args]),

Notiek ielāde…
Atcelt
Saglabāt