Remove log handler for alarms
This commit is contained in:
parent
1bf68f4807
commit
7472e531b1
|
@ -38,8 +38,6 @@ start(_Type, _Args) ->
|
||||||
register(emqx, self()),
|
register(emqx, self()),
|
||||||
|
|
||||||
emqx_alarm_handler:load(),
|
emqx_alarm_handler:load(),
|
||||||
emqx_logger_handler:init(),
|
|
||||||
|
|
||||||
print_vsn(),
|
print_vsn(),
|
||||||
{ok, Sup}.
|
{ok, Sup}.
|
||||||
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
|
||||||
%%
|
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
%% you may not use this file except in compliance with the License.
|
|
||||||
%% You may obtain a copy of the License at
|
|
||||||
%%
|
|
||||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
%%
|
|
||||||
%% Unless required by applicable law or agreed to in writing, software
|
|
||||||
%% distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
%% See the License for the specific language governing permissions and
|
|
||||||
%% limitations under the License.
|
|
||||||
|
|
||||||
-module(emqx_logger_handler).
|
|
||||||
|
|
||||||
-export([log/2]).
|
|
||||||
|
|
||||||
-export([init/0]).
|
|
||||||
|
|
||||||
init() ->
|
|
||||||
logger:add_handler(emqx_logger_handler,
|
|
||||||
emqx_logger_handler,
|
|
||||||
#{level => error,
|
|
||||||
filters => [{easy_filter, {fun filter_by_level/2, []}}],
|
|
||||||
filters_default => stop}).
|
|
||||||
|
|
||||||
-spec log(LogEvent, Config) -> ok when LogEvent :: logger:log_event(), Config :: logger:handler_config().
|
|
||||||
log(#{msg := {report, #{report := [{supervisor, SupName},
|
|
||||||
{errorContext, Error},
|
|
||||||
{reason, Reason},
|
|
||||||
{offender, _}]}}}, _Config) ->
|
|
||||||
alarm_handler:set_alarm({supervisor_report, [{supervisor, SupName},
|
|
||||||
{errorContext, Error},
|
|
||||||
{reason, Reason}]}),
|
|
||||||
ok;
|
|
||||||
log(_LogEvent, _Config) ->
|
|
||||||
ok.
|
|
||||||
|
|
||||||
filter_by_level(LogEvent = #{level := error}, _Extra) ->
|
|
||||||
LogEvent;
|
|
||||||
filter_by_level(_LogEvent, _Extra) ->
|
|
||||||
stop.
|
|
|
@ -24,8 +24,7 @@
|
||||||
-include("emqx_mqtt.hrl").
|
-include("emqx_mqtt.hrl").
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
|
|
||||||
all() -> [t_alarm_handler,
|
all() -> [t_alarm_handler].
|
||||||
t_logger_handler].
|
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
emqx_ct_helpers:start_apps([], fun set_special_configs/1),
|
emqx_ct_helpers:start_apps([], fun set_special_configs/1),
|
||||||
|
@ -97,23 +96,6 @@ t_alarm_handler(_) ->
|
||||||
|
|
||||||
end).
|
end).
|
||||||
|
|
||||||
t_logger_handler(_) ->
|
|
||||||
%% Meck supervisor report
|
|
||||||
logger:log(error, #{label => {supervisor, start_error},
|
|
||||||
report => [{supervisor, {local, tmp_sup}},
|
|
||||||
{errorContext, shutdown},
|
|
||||||
{reason, reached_max_restart_intensity},
|
|
||||||
{offender, [{pid, meck},
|
|
||||||
{id, meck},
|
|
||||||
{mfargs, {meck, start_link, []}},
|
|
||||||
{restart_type, permanent},
|
|
||||||
{shutdown, 5000},
|
|
||||||
{child_type, worker}]}]},
|
|
||||||
#{logger_formatter => #{title => "SUPERVISOR REPORT"},
|
|
||||||
report_cb => fun logger:format_otp_report/1}),
|
|
||||||
timer:sleep(20),
|
|
||||||
?assertEqual(true, lists:keymember(supervisor_report, 1, emqx_alarm_handler:get_alarms())).
|
|
||||||
|
|
||||||
raw_send_serialize(Packet) ->
|
raw_send_serialize(Packet) ->
|
||||||
emqx_frame:serialize(Packet).
|
emqx_frame:serialize(Packet).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue