diff options
author | Björn Gustavsson <[email protected]> | 2015-09-09 12:37:52 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-09-09 12:37:52 +0200 |
commit | d307079cc7b88f89e8cf68fe189d1d329a47ad51 (patch) | |
tree | abfb7a4a861717f3b3704adb707293d0024bad26 /lib/sasl/src/sasl_report.erl | |
parent | 439de942a4db2a422dbfe7813f66b150f947313f (diff) | |
parent | d73f47345776d3567b50115af69d551077909514 (diff) | |
download | otp-d307079cc7b88f89e8cf68fe189d1d329a47ad51.tar.gz otp-d307079cc7b88f89e8cf68fe189d1d329a47ad51.tar.bz2 otp-d307079cc7b88f89e8cf68fe189d1d329a47ad51.zip |
Merge branch 'bjorn/error-loggers/OTP-12864' into maint
* bjorn/error-loggers/OTP-12864:
Add documentation
Introduce sasl_report_SUITE
Teach sasl_report to limit crash reports
proc_lib: Add format/3
Teach error_logger_tty_h to truncate big messages
error_logger_tty_h: Refactor and modernize code
Teach error_logger_file_h to truncate big messages
error_logger_file_h: Refactor and modernize code
Remove unused code in error logger handlers
Add error_logger_h_SUITE
sasl_SUITE: Add a rudimentary test of the utc_log configuration
sasl_SUITE: Correct the log_file/1 test case
proc_lib_SUITE: Remove added report handlers
zip_SUITE: Don't trust priv_dir to be empty
Diffstat (limited to 'lib/sasl/src/sasl_report.erl')
-rw-r--r-- | lib/sasl/src/sasl_report.erl | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/lib/sasl/src/sasl_report.erl b/lib/sasl/src/sasl_report.erl index 1b1d432352..0b8c4212d2 100644 --- a/lib/sasl/src/sasl_report.erl +++ b/lib/sasl/src/sasl_report.erl @@ -62,27 +62,53 @@ write_report2(IO, Fd, Head, supervisor_report, Report) -> Context = sup_get(errorContext, Report), Reason = sup_get(reason, Report), Offender = sup_get(offender, Report), - FmtString = " Supervisor: ~p~n Context: ~p~n Reason: " - "~80.18p~n Offender: ~80.18p~n~n", - write_report_action(IO, Fd, Head ++ FmtString, - [Name,Context,Reason,Offender]); + {FmtString,Args} = supervisor_format([Name,Context,Reason,Offender]), + write_report_action(IO, Fd, Head, FmtString, Args); write_report2(IO, Fd, Head, progress, Report) -> Format = format_key_val(Report), - write_report_action(IO, Fd, Head ++ "~s", [Format]); + write_report_action(IO, Fd, Head, "~s", [Format]); write_report2(IO, Fd, Head, crash_report, Report) -> - Format = proc_lib:format(Report), - write_report_action(IO, Fd, Head ++ "~s", [Format]). + Depth = get_depth(), + Format = proc_lib:format(Report, latin1, Depth), + write_report_action(IO, Fd, Head, "~s", [Format]). + +supervisor_format(Args0) -> + case get_depth() of + unlimited -> + {" Supervisor: ~p~n" + " Context: ~p~n" + " Reason: ~80.18p~n" + " Offender: ~80.18p~n~n", + Args0}; + Depth -> + [A,B,C,D] = Args0, + Args = [A,Depth,B,Depth,C,Depth,D,Depth], + {" Supervisor: ~P~n" + " Context: ~P~n" + " Reason: ~80.18P~n" + " Offender: ~80.18P~n~n", + Args} + end. -write_report_action(io, Fd, Format, Args) -> - io:format(Fd, Format, Args); -write_report_action(io_lib, _Fd, Format, Args) -> - io_lib:format(Format, Args). +write_report_action(IO, Fd, Head, Format, Args) -> + S = [Head|io_lib:format(Format, Args)], + case IO of + io -> io:put_chars(Fd, S); + io_lib -> S + end. format_key_val([{Tag,Data}|Rep]) -> io_lib:format(" ~16w: ~p~n",[Tag,Data]) ++ format_key_val(Rep); format_key_val(_) -> []. +get_depth() -> + case application:get_env(kernel, error_logger_format_depth) of + {ok, Depth} when is_integer(Depth) -> + max(10, Depth); + undefined -> + unlimited + end. sup_get(Tag, Report) -> case lists:keysearch(Tag, 1, Report) of |