diff options
author | Siri Hansen <[email protected]> | 2018-09-11 11:18:52 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2018-09-12 14:58:02 +0200 |
commit | 48a1c458a46dcd1f031fd3b9689af80b32b4a6a2 (patch) | |
tree | beb11e46fbf6f815c673053ab75a5be64d61d098 | |
parent | 98bfd0c19ca1f563c18c252d58801c2c5731861a (diff) | |
download | otp-48a1c458a46dcd1f031fd3b9689af80b32b4a6a2.tar.gz otp-48a1c458a46dcd1f031fd3b9689af80b32b4a6a2.tar.bz2 otp-48a1c458a46dcd1f031fd3b9689af80b32b4a6a2.zip |
[error_logger] Handle report_cb with arity 2
-rw-r--r-- | lib/kernel/src/error_logger.erl | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/kernel/src/error_logger.erl b/lib/kernel/src/error_logger.erl index ad8c937882..e324be5290 100644 --- a/lib/kernel/src/error_logger.erl +++ b/lib/kernel/src/error_logger.erl @@ -147,14 +147,27 @@ do_log(Level,{report,Msg},#{?MODULE:=#{tag:=Tag}}=Meta) -> _ -> %% From logger call which added error_logger data to %% obtain backwards compatibility with error_logger:*_msg/1,2 - RCBFun=maps:get(report_cb,Meta,fun logger:format_report/1), - try RCBFun(Msg) of - {F,A} when is_list(F), is_list(A) -> - {F,A}; - Other -> - {"REPORT_CB ERROR: ~tp; Returned: ~tp",[Msg,Other]} - catch C:R -> - {"REPORT_CB CRASH: ~tp; Reason: ~tp",[Msg,{C,R}]} + case maps:get(report_cb,Meta,fun logger:format_report/1) of + RCBFun when is_function(RCBFun,1) -> + try RCBFun(Msg) of + {F,A} when is_list(F), is_list(A) -> + {F,A}; + Other -> + {"REPORT_CB ERROR: ~tp; Returned: ~tp",[Msg,Other]} + catch C:R -> + {"REPORT_CB CRASH: ~tp; Reason: ~tp",[Msg,{C,R}]} + end; + RCBFun when is_function(RCBFun,2) -> + try RCBFun(Msg,#{depth=>get_format_depth(), + chars_limit=>unlimited, + single_line=>false}) of + Chardata when ?IS_STRING(Chardata) -> + {"~ts",[Chardata]}; + Other -> + {"REPORT_CB ERROR: ~tp; Returned: ~tp",[Msg,Other]} + catch C:R -> + {"REPORT_CB CRASH: ~tp; Reason: ~tp",[Msg,{C,R}]} + end end end, notify(Level,Tag,Format,Args,Meta); |