diff options
author | Hans Bolinder <[email protected]> | 2017-05-19 14:53:28 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2017-05-19 14:53:28 +0200 |
commit | a8172e4022e3de947c910feb777650be42900059 (patch) | |
tree | ff9c44c138217521531df27f0a65c0581de2a94e /lib/kernel/src/error_logger.erl | |
parent | 166d11bb8cbb386dfab4fef37f6f231ac2689b61 (diff) | |
parent | 0b1fe37dbcfaad9b28ef529aa4f7b4be60ec5da8 (diff) | |
download | otp-a8172e4022e3de947c910feb777650be42900059.tar.gz otp-a8172e4022e3de947c910feb777650be42900059.tar.bz2 otp-a8172e4022e3de947c910feb777650be42900059.zip |
Merge branch 'hasse/kernel/limit_crash_reports/OTP-14417'
* hasse/kernel/limit_crash_reports/OTP-14417:
stdlib: Limit the size of gen_statem's error events
kernel: Introcude error_logger:get_format_depth()
stdlib: Limit the size of proc_lib's crash reports
stdlib: Limit the size of gen_server's error events
kernel: Add error_logger:limit_term/1
stdlib: Add io_lib:limit_term/2
Diffstat (limited to 'lib/kernel/src/error_logger.erl')
-rw-r--r-- | lib/kernel/src/error_logger.erl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/kernel/src/error_logger.erl b/lib/kernel/src/error_logger.erl index 81f1bf8d97..9bf8547745 100644 --- a/lib/kernel/src/error_logger.erl +++ b/lib/kernel/src/error_logger.erl @@ -31,6 +31,8 @@ handle_event/2, handle_call/2, handle_info/2, terminate/2]). +-export([get_format_depth/0, limit_term/1]). + -define(buffer_size, 10). %%----------------------------------------------------------------- @@ -518,3 +520,21 @@ string_p1([H|T]) when is_list(H) -> end; string_p1([]) -> true; string_p1(_) -> false. + +-spec limit_term(term()) -> term(). + +limit_term(Term) -> + case get_format_depth() of + unlimited -> Term; + D -> io_lib:limit_term(Term, D) + end. + +-spec get_format_depth() -> 'unlimited' | pos_integer(). + +get_format_depth() -> + case application:get_env(kernel, error_logger_format_depth) of + {ok, Depth} when is_integer(Depth) -> + max(10, Depth); + undefined -> + unlimited + end. |