|
|
@ -9,9 +9,9 @@ |
|
|
|
|
|
|
|
-export([ |
|
|
|
setHighWater/1 |
|
|
|
, format_reason/1 |
|
|
|
, format_mfa/1 |
|
|
|
, format_args/2 |
|
|
|
, formatReason/1 |
|
|
|
, formatMfa/1 |
|
|
|
, formatArgs/2 |
|
|
|
]). |
|
|
|
|
|
|
|
-export([ |
|
|
@ -193,7 +193,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) -> |
|
|
|
{R, N} |
|
|
|
end, |
|
|
|
?CRASH_LOG(Event), |
|
|
|
{Md, Formatted} = format_reason_md(Reason), |
|
|
|
{Md, Formatted} = formatReasonMd(Reason), |
|
|
|
?LOGFMT(Sink, error, [{pid, Pid}, {name, Name} | Md], "gen_server ~w terminated with reason: ~s", [Name, Formatted]); |
|
|
|
"** gen_ipc State machine " ++ _ -> |
|
|
|
%% gen_server terminate |
|
|
@ -210,7 +210,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) -> |
|
|
|
{R, N} |
|
|
|
end, |
|
|
|
?CRASH_LOG(Event), |
|
|
|
{Md, Formatted} = format_reason_md(Reason), |
|
|
|
{Md, Formatted} = formatReasonMd(Reason), |
|
|
|
?LOGFMT(Sink, error, [{pid, Pid}, {name, Name} | Md], "gen_ipc ~w terminated with reason: ~s", [Name, Formatted]); |
|
|
|
"** State machine " ++ _ -> |
|
|
|
%% Check if the terminated process is gen_fsm or gen_statem |
|
|
@ -232,13 +232,13 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) -> |
|
|
|
%% sometimes gen_statem wraps its statename/data in a list for some reason??? |
|
|
|
{gen_statem, TName, TStateName, {TReason, Stacktrace}} |
|
|
|
end, |
|
|
|
{Md, Formatted} = format_reason_md(Reason), |
|
|
|
{Md, Formatted} = formatReasonMd(Reason), |
|
|
|
?CRASH_LOG(Event), |
|
|
|
?LOGFMT(Sink, error, [{pid, Pid}, {name, Name} | Md], "~s ~w in state ~w terminated with reason: ~s", [Type, Name, StateName, Formatted]); |
|
|
|
"** gen_event handler" ++ _ -> |
|
|
|
%% gen_event handler terminate |
|
|
|
[ID, Name, _Msg, _State, Reason] = Args, |
|
|
|
{Md, Formatted} = format_reason_md(Reason), |
|
|
|
{Md, Formatted} = formatReasonMd(Reason), |
|
|
|
?CRASH_LOG(Event), |
|
|
|
?LOGFMT(Sink, error, [{pid, Pid}, {name, Name} | Md], "gen_event ~w installed in ~w terminated with reason: ~s", [ID, Name, Formatted]); |
|
|
|
"** Cowboy handler" ++ _ -> |
|
|
@ -253,7 +253,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) -> |
|
|
|
[Module, Function, Arity, _Class, Reason | Tail] -> |
|
|
|
%% any other cowboy error_format list *always* ends with the stacktrace |
|
|
|
StackTrace = lists:last(Tail), |
|
|
|
{Md, Formatted} = format_reason_md({Reason, StackTrace}), |
|
|
|
{Md, Formatted} = formatReasonMd({Reason, StackTrace}), |
|
|
|
?LOGFMT(Sink, error, [{pid, Pid} | Md], |
|
|
|
"Cowboy handler ~p terminated in ~p:~p/~p with reason: ~s", [Module, Module, Function, Arity, Formatted]) |
|
|
|
end; |
|
|
@ -263,19 +263,19 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) -> |
|
|
|
case Args of |
|
|
|
%% Error logged by cowboy, which starts as ranch error |
|
|
|
[Ref, ConnectionPid, StreamID, RequestPid, Reason, StackTrace] -> |
|
|
|
{Md, Formatted} = format_reason_md({Reason, StackTrace}), |
|
|
|
{Md, Formatted} = formatReasonMd({Reason, StackTrace}), |
|
|
|
?LOGFMT(Sink, error, [{pid, RequestPid} | Md], |
|
|
|
"Cowboy stream ~p with ranch listener ~p and connection process ~p " |
|
|
|
"had its request process exit with reason: ~s", [StreamID, Ref, ConnectionPid, Formatted]); |
|
|
|
[Ref, _Protocol, Worker, {[{reason, Reason}, {mfa, {Module, Function, Arity}}, {stacktrace, StackTrace} | _], _}] -> |
|
|
|
{Md, Formatted} = format_reason_md({Reason, StackTrace}), |
|
|
|
{Md, Formatted} = formatReasonMd({Reason, StackTrace}), |
|
|
|
?LOGFMT(Sink, error, [{pid, Worker} | Md], "Ranch listener ~p terminated in ~p:~p/~p with reason: ~s", [Ref, Module, Function, Arity, Formatted]); |
|
|
|
[Ref, _Protocol, Worker, Reason] -> |
|
|
|
{Md, Formatted} = format_reason_md(Reason), |
|
|
|
{Md, Formatted} = formatReasonMd(Reason), |
|
|
|
?LOGFMT(Sink, error, [{pid, Worker} | Md], "Ranch listener ~p terminated with reason: ~s", [Ref, Formatted]); |
|
|
|
[Ref, Protocol, Ret] -> |
|
|
|
%% ranch_conns_sup.erl module line 119-123 has three parameters error msg, log it. |
|
|
|
{Md, Formatted} = format_reason_md(Ret), |
|
|
|
{Md, Formatted} = formatReasonMd(Ret), |
|
|
|
?LOGFMT(Sink, error, [{pid, Protocol} | Md], "Ranch listener ~p terminated with result:~s", [Ref, Formatted]) |
|
|
|
end; |
|
|
|
"webmachine error" ++ _ -> |
|
|
@ -290,7 +290,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) -> |
|
|
|
_ -> |
|
|
|
Error |
|
|
|
end, |
|
|
|
{Md, Formatted} = format_reason_md(StackTrace), |
|
|
|
{Md, Formatted} = formatReasonMd(StackTrace), |
|
|
|
?LOGFMT(Sink, error, [{pid, Pid} | Md], "Webmachine error at path ~p : ~s", [Path, Formatted]) |
|
|
|
end; |
|
|
|
_ -> |
|
|
@ -299,18 +299,18 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) -> |
|
|
|
end; |
|
|
|
{error_report, _GL, {Pid, std_error, D}} -> |
|
|
|
?CRASH_LOG(Event), |
|
|
|
?LOGMSG(Sink, error, Pid, print_silly_list(D)); |
|
|
|
?LOGMSG(Sink, error, Pid, printSillyList(D)); |
|
|
|
{error_report, _GL, {Pid, supervisor_report, D}} -> |
|
|
|
?CRASH_LOG(Event), |
|
|
|
case lists:sort(D) of |
|
|
|
[{errorContext, Ctx}, {offender, Off}, {reason, Reason}, {supervisor, Name}] -> |
|
|
|
Offender = format_offender(Off), |
|
|
|
{Md, Formatted} = format_reason_md(Reason), |
|
|
|
Offender = formatOffender(Off), |
|
|
|
{Md, Formatted} = formatReasonMd(Reason), |
|
|
|
?LOGFMT(Sink, error, [{pid, Pid} | Md], |
|
|
|
"Supervisor ~w had child ~s exit with reason ~s in context ~w", |
|
|
|
[supervisor_name(Name), Offender, Formatted, Ctx]); |
|
|
|
[supervisorName(Name), Offender, Formatted, Ctx]); |
|
|
|
_ -> |
|
|
|
?LOGMSG(Sink, error, Pid, "SUPERVISOR REPORT " ++ print_silly_list(D)) |
|
|
|
?LOGMSG(Sink, error, Pid, <<"SUPERVISOR REPORT ", (printSillyList(D))/binary>>) |
|
|
|
end; |
|
|
|
{error_report, _GL, {Pid, crash_report, [Self, Neighbours]}} -> |
|
|
|
?CRASH_LOG(Event), |
|
|
@ -319,7 +319,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) -> |
|
|
|
{warning_msg, _GL, {Pid, Fmt, Args}} -> |
|
|
|
?LOGFMT(Sink, warning, Pid, Fmt, Args); |
|
|
|
{warning_report, _GL, {Pid, std_warning, Report}} -> |
|
|
|
?LOGMSG(Sink, warning, Pid, print_silly_list(Report)); |
|
|
|
?LOGMSG(Sink, warning, Pid, printSillyList(Report)); |
|
|
|
{info_msg, _GL, {Pid, Fmt, Args}} -> |
|
|
|
?LOGFMT(Sink, info, Pid, Fmt, Args); |
|
|
|
{info_report, _GL, {Pid, std_info, D}} when is_list(D) -> |
|
|
@ -330,12 +330,12 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) -> |
|
|
|
true when Reason == stopped -> |
|
|
|
no_log; |
|
|
|
_ -> |
|
|
|
{Md, Formatted} = format_reason_md(Reason), |
|
|
|
{Md, Formatted} = formatReasonMd(Reason), |
|
|
|
?LOGFMT(Sink, info, [{pid, Pid} | Md], "Application ~w exited with reason: ~s", |
|
|
|
[App, Formatted]) |
|
|
|
end; |
|
|
|
_ -> |
|
|
|
?LOGMSG(Sink, info, Pid, print_silly_list(D)) |
|
|
|
?LOGMSG(Sink, info, Pid, printSillyList(D)) |
|
|
|
end; |
|
|
|
{info_report, _GL, {Pid, std_info, D}} -> |
|
|
|
?LOGFMT(Sink, info, Pid, "~w", [D]); |
|
|
@ -355,13 +355,13 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) -> |
|
|
|
true -> |
|
|
|
no_log; |
|
|
|
_ -> |
|
|
|
MFA = format_mfa(get_value(mfargs, Started)), |
|
|
|
MFA = formatMfa(get_value(mfargs, Started)), |
|
|
|
Pid = get_value(pid, Started), |
|
|
|
?LOGFMT(Sink, debug, P, "Supervisor ~w started ~s at pid ~w", |
|
|
|
[supervisor_name(Name), MFA, Pid]) |
|
|
|
[supervisorName(Name), MFA, Pid]) |
|
|
|
end; |
|
|
|
_ -> |
|
|
|
?LOGMSG(Sink, info, P, "PROGRESS REPORT " ++ print_silly_list(D)) |
|
|
|
?LOGMSG(Sink, info, P, <<"PROGRESS REPORT ", (printSillyList(D))/binary>>) |
|
|
|
end; |
|
|
|
_ -> |
|
|
|
?LOGFMT(Sink, warning, self(), "Unexpected error_logger event ~w", [Event]) |
|
|
@ -393,83 +393,82 @@ format_crash_report(Report, Neighbours) -> |
|
|
|
end, |
|
|
|
|
|
|
|
{Class, Reason, Trace} = get_value(error_info, Report), |
|
|
|
{Md, ReasonStr} = format_reason_md({Reason, Trace}), |
|
|
|
{Md, ReasonStr} = formatReasonMd({Reason, Trace}), |
|
|
|
Type = ?IIF(Class == exit, <<"exited">>, <<"crashed">>), |
|
|
|
{Md0 ++ Md, eFmt:formatBin("Process ~w with ~w neighbours ~s with reason: ~s", [Name, length(Neighbours), Type, ReasonStr])}. |
|
|
|
|
|
|
|
format_offender(Off) -> |
|
|
|
formatOffender(Off) -> |
|
|
|
case get_value(mfargs, Off) of |
|
|
|
undefined -> |
|
|
|
%% supervisor_bridge |
|
|
|
io_lib:format("at module ~w at ~w", |
|
|
|
[get_value(mod, Off), get_value(pid, Off)]); |
|
|
|
eFmt:formatBin(<<"at module ~w at ~w">>, [get_value(mod, Off), get_value(pid, Off)]); |
|
|
|
MFArgs -> |
|
|
|
%% regular supervisor |
|
|
|
{_, MFA} = formatMfaMd(MFArgs), |
|
|
|
|
|
|
|
%% In 2014 the error report changed from `name' to |
|
|
|
%% `id', so try that first. |
|
|
|
Name = case get_value(id, Off) of |
|
|
|
undefined -> |
|
|
|
get_value(name, Off); |
|
|
|
Id -> |
|
|
|
Id |
|
|
|
end, |
|
|
|
io_lib:format("~p started with ~s at ~w", |
|
|
|
[Name, MFA, get_value(pid, Off)]) |
|
|
|
Name = |
|
|
|
case get_value(id, Off) of |
|
|
|
undefined -> |
|
|
|
get_value(name, Off); |
|
|
|
Id -> |
|
|
|
Id |
|
|
|
end, |
|
|
|
class="nn">eFmt class="p">:formatBin(<<"at module ~w at ~w">>, [Name, MFA, get_value(pid, Off)]) |
|
|
|
end. |
|
|
|
|
|
|
|
%% backwards compatability shim |
|
|
|
format_reason(Reason) -> |
|
|
|
element(2, format_reason_md(Reason)). |
|
|
|
formatReason(Reason) -> |
|
|
|
element(2, formatReasonMd(Reason)). |
|
|
|
|
|
|
|
-spec format_reason_md(Stacktrace :: any()) -> {Metadata :: [{atom(), any()}], String :: list()}. |
|
|
|
format_reason_md({'function not exported', [{M, F, A}, MFA | _]}) -> |
|
|
|
-spec formatReasonMd(Stacktrace :: any()) -> {Metadata :: [{atom(), any()}], String :: list()}. |
|
|
|
formatReasonMd({'function not exported', [{M, F, A}, MFA | _]}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{_, Formatted2} = formatMfaMd({M, F, length(A)}), |
|
|
|
{[{reason, 'function not exported'} | Md], ["call to undefined function ", Formatted2, " from ", Formatted]}; |
|
|
|
format_reason_md({'function not exported', [{M, F, A, _Props}, MFA | _]}) -> |
|
|
|
{[{reason, 'function not exported'} | Md], <<"call to undefined function ", Formatted2/binary, " from ", Formatted/binary>>}; |
|
|
|
formatReasonMd({'function not exported', [{M, F, A, _Props}, MFA | _]}) -> |
|
|
|
%% R15 line numbers |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{_, Formatted2} = formatMfaMd({M, F, length(A)}), |
|
|
|
{[{reason, 'function not exported'} | Md], ["call to undefined function ", Formatted2, " from ", Formatted]}; |
|
|
|
format_reason_md({undef, [MFA | _]}) -> |
|
|
|
{[{reason, 'function not exported'} | Md], <<"call to undefined function ", Formatted2/binary, " from ", Formatted/binary>>}; |
|
|
|
formatReasonMd({undef, [MFA | _]}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, undef} | Md], ["call to undefined function ", Formatted]}; |
|
|
|
format_reason_md({bad_return, {_MFA, {'EXIT', Reason}}}) -> |
|
|
|
format_reason_md(Reason); |
|
|
|
format_reason_md({bad_return, {MFA, Val}}) -> |
|
|
|
{[{reason, undef} | Md], <<"call to undefined function ", Formatted/binary>>}; |
|
|
|
formatReasonMd({bad_return, {_MFA, {'EXIT', Reason}}}) -> |
|
|
|
formatReasonMd(Reason); |
|
|
|
formatReasonMd({bad_return, {MFA, Val}}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, bad_return} | Md], ["bad return value ", print_val(Val), " from ", Formatted]}; |
|
|
|
format_reason_md({bad_return_value, Val}) -> |
|
|
|
{[{reason, bad_return}], ["bad return value: ", print_val(Val)]}; |
|
|
|
format_reason_md({{bad_return_value, Val}, MFA}) -> |
|
|
|
{[{reason, bad_return} | Md], <<"bad return value ", (formatVal(Val))/binary, " from ", Formatted/binary>>}; |
|
|
|
formatReasonMd({bad_return_value, Val}) -> |
|
|
|
{[{reason, bad_return}], <<"bad return value: ", (formatVal(Val))/binary>>}; |
|
|
|
formatReasonMd({{bad_return_value, Val}, MFA}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, bad_return_value} | Md], ["bad return value: ", print_val(Val), " in ", Formatted]}; |
|
|
|
format_reason_md({{badrecord, Record}, [MFA | _]}) -> |
|
|
|
{[{reason, bad_return_value} | Md], <<"bad return value: ", (formatVal(Val))/binary, " in ", Formatted/binary>>}; |
|
|
|
formatReasonMd({{badrecord, Record}, [MFA | _]}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, badrecord} | Md], ["bad record ", print_val(Record), " in ", Formatted]}; |
|
|
|
format_reason_md({{case_clause, Val}, [MFA | _]}) -> |
|
|
|
{[{reason, badrecord} | Md], <<"bad record ", (formatVal(Record))/binary, " in ", Formatted/binary>>}; |
|
|
|
formatReasonMd({{case_clause, Val}, [MFA | _]}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, case_clause} | Md], ["no case clause matching ", print_val(Val), " in ", Formatted]}; |
|
|
|
format_reason_md({function_clause, [MFA | _]}) -> |
|
|
|
{[{reason, case_clause} | Md], <<"no case clause matching ", (formatVal(Val))/binary, " in ", Formatted/binary>>}; |
|
|
|
formatReasonMd({function_clause, [MFA | _]}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, function_clause} | Md], ["no function clause matching ", Formatted]}; |
|
|
|
format_reason_md({if_clause, [MFA | _]}) -> |
|
|
|
{[{reason, function_clause} | Md], <<"no function clause matching ", Formatted/binary>>}; |
|
|
|
formatReasonMd({if_clause, [MFA | _]}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, if_clause} | Md], ["no true branch found while evaluating if expression in ", Formatted]}; |
|
|
|
format_reason_md({{try_clause, Val}, [MFA | _]}) -> |
|
|
|
{[{reason, if_clause} | Md], <<"no true branch found while evaluating if expression in ", Formatted/binary>>}; |
|
|
|
formatReasonMd({{try_clause, Val}, [MFA | _]}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, try_clause} | Md], ["no try clause matching ", print_val(Val), " in ", Formatted]}; |
|
|
|
format_reason_md({badarith, [MFA | _]}) -> |
|
|
|
{[{reason, try_clause} | Md], <<"no try clause matching ", (formatVal(Val))/binary, " in ", Formatted/binary>>}; |
|
|
|
formatReasonMd({badarith, [MFA | _]}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, badarith} | Md], ["bad arithmetic expression in ", Formatted]}; |
|
|
|
format_reason_md({{badmatch, Val}, [MFA | _]}) -> |
|
|
|
{[{reason, badarith} | Md], <<"bad arithmetic expression in ", Formatted/binary>>}; |
|
|
|
formatReasonMd({{badmatch, Val}, [MFA | _]}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, badmatch} | Md], ["no match of right hand value ", print_val(Val), " in ", Formatted]}; |
|
|
|
format_reason_md({emfile, _Trace}) -> |
|
|
|
{[{reason, emfile}], "maximum number of file descriptors exhausted, check ulimit -n"}; |
|
|
|
format_reason_md({system_limit, [{M, F, _} | _] = Trace}) -> |
|
|
|
{[{reason, badmatch} | Md], <<"no match of right hand value ", (formatVal(Val))/binary, " in ", Formatted/binary>>}; |
|
|
|
formatReasonMd({emfile, _Trace}) -> |
|
|
|
{[{reason, emfile}], <<"maximum number of file descriptors exhausted, check ulimit -n";>>}; |
|
|
|
formatReasonMd({system_limit, [{M, F, _} | _] = Trace}) -> |
|
|
|
Limit = |
|
|
|
case {M, F} of |
|
|
|
{erlang, open_port} -> |
|
|
@ -485,62 +484,54 @@ format_reason_md({system_limit, [{M, F, _} | _] = Trace}) -> |
|
|
|
_ -> |
|
|
|
eFmt:formatBin(<<"~p">>, [Trace], [{charsLimit, 500}]) |
|
|
|
end, |
|
|
|
{[{reason, system_limit}], ["system limit: ", Limit]}; |
|
|
|
format_reason_md({badarg, [MFA, MFA2 | _]}) -> |
|
|
|
{[{reason, system_limit}], <<"system limit: ", Limit/binary>>}; |
|
|
|
formatReasonMd({badarg, [MFA, MFA2 | _]}) -> |
|
|
|
case MFA of |
|
|
|
{_M, _F, A, _Props} when is_list(A) -> |
|
|
|
%% R15 line numbers |
|
|
|
{Md, Formatted} = formatMfaMd(MFA2), |
|
|
|
{_, Formatted2} = formatMfaMd(MFA), |
|
|
|
{[{reason, badarg} | Md], |
|
|
|
["bad argument in call to ", Formatted2, " in ", Formatted]}; |
|
|
|
{[{reason, badarg} | Md], <<"bad argument in call to ", Formatted2, " in ", Formatted/binary>>}; |
|
|
|
{_M, _F, A} when is_list(A) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA2), |
|
|
|
{_, Formatted2} = formatMfaMd(MFA), |
|
|
|
{[{reason, badarg} | Md], |
|
|
|
["bad argument in call to ", Formatted2, " in ", Formatted]}; |
|
|
|
{[{reason, badarg} | Md], <<"bad argument in call to ", Formatted2, " in ", Formatted/binary>>}; |
|
|
|
_ -> |
|
|
|
%% seems to be generated by a bad call to a BIF |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, badarg} | Md], |
|
|
|
["bad argument in ", Formatted]} |
|
|
|
{[{reason, badarg} | Md], <<"bad argument in ", Formatted/binary>>} |
|
|
|
end; |
|
|
|
format_reason_md({{badarg, Stack}, _}) -> |
|
|
|
format_reason_md({badarg, Stack}); |
|
|
|
format_reason_md({{badarity, {Fun, Args}}, [MFA | _]}) -> |
|
|
|
formatReasonMd({{badarg, Stack}, _}) -> |
|
|
|
formatReasonMd({badarg, Stack}); |
|
|
|
formatReasonMd({{badarity, {Fun, Args}}, [MFA | _]}) -> |
|
|
|
{arity, Arity} = lists:keyfind(arity, 1, erlang:fun_info(Fun)), |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, badarity} | Md], |
|
|
|
[io_lib:format("fun called with wrong arity of ~w instead of ~w in ", |
|
|
|
[length(Args), Arity]), Formatted]}; |
|
|
|
format_reason_md({noproc, MFA}) -> |
|
|
|
{[{reason, badarity} | Md], eFmt:formatBin("fun called with wrong arity of ~w instead of ~w in ~s", [length(Args), Arity, Formatted])}; |
|
|
|
formatReasonMd({noproc, MFA}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, noproc} | Md], |
|
|
|
["no such process or port in call to ", Formatted]}; |
|
|
|
format_reason_md({{badfun, Term}, [MFA | _]}) -> |
|
|
|
{[{reason, noproc} | Md], <<"no such process or port in call to ", Formatted/binary>>}; |
|
|
|
formatReasonMd({{badfun, Term}, [MFA | _]}) -> |
|
|
|
{Md, Formatted} = formatMfaMd(MFA), |
|
|
|
{[{reason, badfun} | Md], |
|
|
|
["bad function ", print_val(Term), " in ", Formatted]}; |
|
|
|
format_reason_md({Reason, [{M, F, A} | _]}) when is_atom(M), is_atom(F), is_integer(A) -> |
|
|
|
{Md, Formatted} = format_reason_md(Reason), |
|
|
|
{[{reason, badfun} | Md], <<"bad function ", (formatVal(Term))/binary, " in ", Formatted/binary>>}; |
|
|
|
formatReasonMd({Reason, [{M, F, A} | _]}) when is_atom(M), is_atom(F), is_integer(A) -> |
|
|
|
{Md, Formatted} = formatReasonMd(Reason), |
|
|
|
{_, Formatted2} = formatMfaMd({M, F, A}), |
|
|
|
{Md, [Formatted, " in ", Formatted2]}; |
|
|
|
format_reason_md({Reason, [{M, F, A, Props} | _]}) when is_atom(M), is_atom(F), is_integer(A), is_list(Props) -> |
|
|
|
{Md, <<Formatted/binary, " in ", Formatted2/binary>>}; |
|
|
|
formatReasonMd({Reason, [{M, F, A, Props} | _]}) when is_atom(M), is_atom(F), is_integer(A), is_list(Props) -> |
|
|
|
%% line numbers |
|
|
|
{Md, Formatted} = format_reason_md(Reason), |
|
|
|
{Md, Formatted} = formatReasonMd(Reason), |
|
|
|
{_, Formatted2} = formatMfaMd({M, F, A, Props}), |
|
|
|
{Md, [Formatted, " in ", Formatted2]}; |
|
|
|
format_reason_md(Reason) -> |
|
|
|
{Str, _} = rumTruncIo:print(Reason, 500), |
|
|
|
{[], Str}. |
|
|
|
{Md, <<Formatted/binary, " in ", Formatted2/binary>>}; |
|
|
|
formatReasonMd(Reason) -> |
|
|
|
eFtm:formatBin(<<"~p">>, [Reason], [{charsLimit, 500}]). |
|
|
|
|
|
|
|
%% backwards compatability shim |
|
|
|
format_mfa(MFA) -> |
|
|
|
formatMfa(MFA) -> |
|
|
|
element(2, formatMfaMd(MFA)). |
|
|
|
|
|
|
|
-spec formatMfaMd(any()) -> {[{atom(), any()}], list()}. |
|
|
|
formatMfaMd({M, F, A}) when is_list(A) -> |
|
|
|
ArgsStr = format_args(A, <<>>), |
|
|
|
ArgsStr = formatArgs(A, <<>>), |
|
|
|
{[{module, M}, {function, F}], eFtm:formatBin(<<"~w:~w(", ArgsStr/binary, ")">>, [M, F])}; |
|
|
|
formatMfaMd({M, F, A}) when is_integer(A) -> |
|
|
|
{[{module, M}, {function, F}], eFtm:formatBin(<<"~w:~w/~w">>, [M, F, A])}; |
|
|
@ -563,38 +554,20 @@ formatMfaMd([{M, F, A, Props} | _]) when is_list(Props) -> |
|
|
|
formatMfaMd(Other) -> |
|
|
|
{[], eFtm:formatBin(<<"~w">>, [Other])}. |
|
|
|
|
|
|
|
format_args([], ArgsAcc) -> |
|
|
|
formatArgs([], ArgsAcc) -> |
|
|
|
ArgsAcc; |
|
|
|
format_args([H], ArgsAcc) -> |
|
|
|
formatArgs([H], ArgsAcc) -> |
|
|
|
Str = eFmt:formatBin(<<"~p">>, [H], [{charsLimit, 100}]), |
|
|
|
<<ArgsAcc/binary, Str/binary>>; |
|
|
|
format_args([H | T], ArgsAcc) -> |
|
|
|
formatArgs([H | T], ArgsAcc) -> |
|
|
|
Str = eFmt:formatBin(<<"~p">>, [H], [{charsLimit, 100}]), |
|
|
|
format_args(T, <<ArgsAcc/binary, Str/binary, ",">>). |
|
|
|
formatArgs(T, <<ArgsAcc/binary, Str/binary, ",">>). |
|
|
|
|
|
|
|
print_silly_list(L) when is_list(L) -> |
|
|
|
case rumStdlib:string_p(L) of |
|
|
|
true -> |
|
|
|
rumTruncIo:format("~s", [L], ?RumDefTruncation); |
|
|
|
_ -> |
|
|
|
print_silly_list(L, [], []) |
|
|
|
end; |
|
|
|
print_silly_list(L) -> |
|
|
|
{Str, _} = rumTruncIo:print(L, ?RumDefTruncation), |
|
|
|
Str. |
|
|
|
|
|
|
|
print_silly_list([], Fmt, Acc) -> |
|
|
|
rumTruncIo:format(string:join(lists:reverse(Fmt), ", "), |
|
|
|
lists:reverse(Acc), ?RumDefTruncation); |
|
|
|
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) -> |
|
|
|
print_silly_list(T, ["~p" | Fmt], [H | Acc]). |
|
|
|
|
|
|
|
print_val(Val) -> |
|
|
|
{Str, _} = rumTruncIo:print(Val, 500), |
|
|
|
Str. |
|
|
|
formatVal(Val) -> |
|
|
|
eFmt:formatBin(<<"~p">>, [Val], [{charsLimit, 500}]). |
|
|
|
|
|
|
|
printSillyList(L) -> |
|
|
|
eFmt:formatBin(<<"~p">>, [L], [{charsLimit, ?RumDefTruncation}]). |
|
|
|
|
|
|
|
%% @doc Faster than proplists, but with the same API as long as you don't need to |
|
|
|
%% handle bare atom keys |
|
|
@ -607,8 +580,8 @@ get_value(Key, List, Default) -> |
|
|
|
{Key, Value} -> Value |
|
|
|
end. |
|
|
|
|
|
|
|
supervisor_name({local, Name}) -> Name; |
|
|
|
supervisor_name(Name) -> Name. |
|
|
|
supervisorName({local, Name}) -> Name; |
|
|
|
supervisorName(Name) -> Name. |
|
|
|
|
|
|
|
-ifdef(TEST). |
|
|
|
-include_lib("eunit/include/eunit.hrl"). |
|
|
|