diff options
| author | Alvaro Videla <videlalvaro@gmail.com> | 2015-09-24 23:50:30 +0200 |
|---|---|---|
| committer | Alvaro Videla <videlalvaro@gmail.com> | 2015-09-24 23:50:30 +0200 |
| commit | 14eb2802c798cc076fa6add331b4c8043056338f (patch) | |
| tree | 03b2af1fc86957a78b4f583efb3b4e1dff0788e2 /src | |
| parent | 793d7bff97fefd25094fd0a93a3bc83c13da2f50 (diff) | |
| download | rabbitmq-server-git-14eb2802c798cc076fa6add331b4c8043056338f.tar.gz | |
handles the error logger state change introduced in Erlang 18.1
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_error_logger_file_h.erl | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/src/rabbit_error_logger_file_h.erl b/src/rabbit_error_logger_file_h.erl index 65ab7fcca8..9d93f6fd6b 100644 --- a/src/rabbit_error_logger_file_h.erl +++ b/src/rabbit_error_logger_file_h.erl @@ -24,6 +24,25 @@ -export([safe_handle_event/3]). +%% extracted from error_logger_file_h. Since 18.1 the state of the +%% error logger module changed. See: +%% https://github.com/erlang/otp/commit/003091a1fcc749a182505ef5675c763f71eacbb0#diff-d9a19ba08f5d2b60fadfc3aa1566b324R108 +%% github issue: +%% https://github.com/rabbitmq/rabbitmq-server/issues/324 +-record(st, + {fd, + filename, + prev_handler, + depth = unlimited}). +%% extracted from error_logger_file_h. See comment above. +get_depth() -> + case application:get_env(kernel, error_logger_format_depth) of + {ok, Depth} when is_integer(Depth) -> + max(10, Depth); + undefined -> + unlimited + end. + %% rabbit_error_logger_file_h is a wrapper around the error_logger_file_h %% module because the original's init/1 does not match properly %% with the result of closing the old handler when swapping handlers. @@ -82,18 +101,32 @@ init_file(File, PrevHandler) -> handle_event(Event, State) -> safe_handle_event(fun handle_event0/2, Event, State). -safe_handle_event(HandleEvent, Event, State) -> +safe_handle_event(HandleEvent, Event, {Fd, File, PrevHandler} = State) -> try HandleEvent(Event, State) catch + _:function_clause -> + State18_1 = #st{fd = Fd, filename = File, + prev_handler = PrevHandler, + depth = get_depth()}, + try + HandleEvent(Event, State18_1) + catch + _:Error -> + io_format_error(Event, Error, erlang:get_stacktrace()), + {ok, State} + end; _:Error -> - io:format( - "Error in log handler~n====================~n" - "Event: ~P~nError: ~P~nStack trace: ~p~n~n", - [Event, 30, Error, 30, erlang:get_stacktrace()]), + io_format_error(Event, Error, erlang:get_stacktrace()), {ok, State} end. +io_format_error(Event, Error, StackTrace) -> + io:format( + "Error in log handler~n====================~n" + "Event: ~P~nError: ~P~nStack trace: ~p~n~n", + [Event, 30, Error, 30, StackTrace]). + %% filter out "application: foo; exited: stopped; type: temporary" handle_event0({info_report, _, {_, std_info, _}}, State) -> {ok, State}; |
