Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make the default truncation limit a macro

  • Loading branch information...
commit 55283cc2c21e8cf3aab0edbac1d5d49d8c18fb4d 1 parent 350ba40
@Vagabond Vagabond authored
View
1  include/lager.hrl
@@ -22,6 +22,7 @@
message
}).
+-define(DEFAULT_TRUNCATION, 4096).
-define(LEVELS,
[debug, info, notice, warning, error, critical, alert, emergency, none]).
View
12 src/error_logger_lager_h.erl
@@ -88,7 +88,7 @@ handle_event(Event, State) ->
[ID, Name, format_reason(Reason)]);
_ ->
?CRASH_LOG(Event),
- ?LOG(error, Pid, lager:safe_format(Fmt, Args, 4096))
+ ?LOG(error, Pid, lager:safe_format(Fmt, Args, ?DEFAULT_TRUNCATION))
end;
{error_report, _GL, {Pid, std_error, D}} ->
?CRASH_LOG(Event),
@@ -108,11 +108,11 @@ handle_event(Event, State) ->
?CRASH_LOG(Event),
?LOG(error, Pid, "CRASH REPORT " ++ format_crash_report(Self, Neighbours));
{warning_msg, _GL, {Pid, Fmt, Args}} ->
- ?LOG(warning, Pid, lager:safe_format(Fmt, Args, 4096));
+ ?LOG(warning, Pid, lager:safe_format(Fmt, Args, ?DEFAULT_TRUNCATION));
{warning_report, _GL, {Pid, std_warning, Report}} ->
?LOG(warning, Pid, print_silly_list(Report));
{info_msg, _GL, {Pid, Fmt, Args}} ->
- ?LOG(info, Pid, lager:safe_format(Fmt, Args, 4096));
+ ?LOG(info, Pid, lager:safe_format(Fmt, Args, ?DEFAULT_TRUNCATION));
{info_report, _GL, {Pid, std_info, D}} when is_list(D) ->
Details = lists:sort(D),
case Details of
@@ -292,17 +292,17 @@ format_args([H|T], FmtAcc, ArgsAcc) ->
print_silly_list(L) when is_list(L) ->
case lager_stdlib:string_p(L) of
true ->
- lager_trunc_io:format("~s", [L], 4096);
+ lager_trunc_io:format("~s", [L], ?DEFAULT_TRUNCATION);
_ ->
print_silly_list(L, [], [])
end;
print_silly_list(L) ->
- {Str, _} = lager_trunc_io:print(L, 4096),
+ {Str, _} = lager_trunc_io:print(L, ?DEFAULT_TRUNCATION),
Str.
print_silly_list([], Fmt, Acc) ->
lager_trunc_io:format(string:join(lists:reverse(Fmt), ", "),
- lists:reverse(Acc), 4096);
+ lists:reverse(Acc), ?DEFAULT_TRUNCATION);
print_silly_list([{K,V}|T], Fmt, Acc) ->
print_silly_list(T, ["~p: ~p" | Fmt], [V, K | Acc]);
print_silly_list([H|T], Fmt, Acc) ->
View
10 src/lager.erl
@@ -87,16 +87,16 @@ dispatch_log(Severity, Metadata, Format, Args, Size) when is_atom(Severity)->
%% @doc Manually log a message into lager without using the parse transform.
-spec log(log_level(), pid() | [tuple(),...], list()) -> ok | {error, lager_not_running}.
log(Level, Pid, Message) when is_pid(Pid) ->
- dispatch_log(Level, [{pid,Pid}], Message, [], 4096);
+ dispatch_log(Level, [{pid,Pid}], Message, [], ?DEFAULT_TRUNCATION);
log(Level, Metadata, Message) when is_list(Metadata) ->
- dispatch_log(Level, Metadata, Message, [], 4096).
+ dispatch_log(Level, Metadata, Message, [], ?DEFAULT_TRUNCATION).
%% @doc Manually log a message into lager without using the parse transform.
-spec log(log_level(), pid() | [tuple(),...], string(), list()) -> ok | {error, lager_not_running}.
log(Level, Pid, Format, Args) when is_pid(Pid) ->
- dispatch_log(Level, [{pid,Pid}], Format, Args, 4096);
+ dispatch_log(Level, [{pid,Pid}], Format, Args, ?DEFAULT_TRUNCATION);
log(Level, Metadata, Format, Args) when is_list(Metadata) ->
- dispatch_log(Level, Metadata, Format, Args, 4096).
+ dispatch_log(Level, Metadata, Format, Args, ?DEFAULT_TRUNCATION).
trace_file(File, Filter) ->
trace_file(File, Filter, debug).
@@ -239,7 +239,7 @@ posix_error(Error) when is_atom(Error) ->
Message -> Message
end;
posix_error(Error) ->
- safe_format_chop("~p", [Error], 4096).
+ safe_format_chop("~p", [Error], ?DEFAULT_TRUNCATION).
%% @private
get_loglevels() ->
View
2  src/lager_transform.erl
@@ -29,7 +29,7 @@
%% @private
parse_transform(AST, Options) ->
- TruncSize = proplists:get_value(lager_truncation_size, Options, 4096),
+ TruncSize = proplists:get_value(lager_truncation_size, Options, ?DEFAULT_TRUNCATION),
put(truncation_size, TruncSize),
walk_ast([], AST).
Please sign in to comment.
Something went wrong with that request. Please try again.