浏览代码

Rename trunc_io to lager_trunc_io to prevent clashes

pull/4/head
Andrew Thompson 14 年前
父节点
当前提交
4ac01374fa
共有 5 个文件被更改,包括 16 次插入12 次删除
  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 查看文件

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

+ 5
- 5
src/lager_crash_log.erl 查看文件

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

+ 3
- 3
src/lager_stdlib.erl 查看文件

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

src/trunc_io.erl → src/lager_trunc_io.erl 查看文件

@ -25,8 +25,12 @@
%% %%
%% Source license: Erlang Public License. %% Source license: Erlang Public License.
%% Original author: Matthias Lang, <tt>matthias@corelatus.se</tt> %% 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'). -author('matthias@corelatus.se').
%% And thanks to Chris Newcombe for a bug fix %% And thanks to Chris Newcombe for a bug fix
-export([format/3, print/2, fprint/2, safe/2]). % interface functions -export([format/3, print/2, fprint/2, safe/2]). % interface functions

+ 1
- 1
test/trunc_io_eqc.erl 查看文件

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

正在加载...
取消
保存