From 4ac01374fa6ca5378327b86b1ac43fd097e70880 Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Fri, 8 Jul 2011 10:18:56 -0400 Subject: [PATCH] Rename trunc_io to lager_trunc_io to prevent clashes --- src/error_logger_lager_h.erl | 4 ++-- src/lager_crash_log.erl | 10 +++++----- src/lager_stdlib.erl | 6 +++--- src/{trunc_io.erl => lager_trunc_io.erl} | 6 +++++- test/trunc_io_eqc.erl | 2 +- 5 files changed, 16 insertions(+), 12 deletions(-) rename src/{trunc_io.erl => lager_trunc_io.erl} (98%) diff --git a/src/error_logger_lager_h.erl b/src/error_logger_lager_h.erl index f393f1f..e751c37 100644 --- a/src/error_logger_lager_h.erl +++ b/src/error_logger_lager_h.erl @@ -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) -> diff --git a/src/lager_crash_log.erl b/src/lager_crash_log.erl index 68e0678..b88d677 100644 --- a/src/lager_crash_log.erl +++ b/src/lager_crash_log.erl @@ -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) -> diff --git a/src/lager_stdlib.erl b/src/lager_stdlib.erl index b8e0bce..a492f7e 100644 --- a/src/lager_stdlib.erl +++ b/src/lager_stdlib.erl @@ -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. diff --git a/src/trunc_io.erl b/src/lager_trunc_io.erl similarity index 98% rename from src/trunc_io.erl rename to src/lager_trunc_io.erl index 288c384..ab0bd19 100644 --- a/src/trunc_io.erl +++ b/src/lager_trunc_io.erl @@ -25,8 +25,12 @@ %% %% Source license: Erlang Public License. %% Original author: Matthias Lang, matthias@corelatus.se +%% +%% Various changes to this module, most notably the format/3 implementation +%% were added by Andrew Thompson . 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 diff --git a/test/trunc_io_eqc.erl b/test/trunc_io_eqc.erl index f97830a..d68f895 100644 --- a/test/trunc_io_eqc.erl +++ b/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 {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]),