ソースを参照

Merge pull request #440 from erlang-lager/adt/dont-log-0-drops

Don't log when we dropped 0 messages
pull/441/head
Mark Allen 7年前
committed by GitHub
コミット
58812d0b49
この署名に対応する既知のキーがデータベースに存在しません GPGキーID: 4AEE18F83AFDEB23
2個のファイルの変更19行の追加9行の削除
  1. +8
    -3
      src/error_logger_lager_h.erl
  2. +11
    -6
      src/lager_file_backend.erl

+ 8
- 3
src/error_logger_lager_h.erl ファイルの表示

@ -126,9 +126,14 @@ handle_event(Event, #state{sink=Sink, shaper=Shaper} = State) ->
end. end.
handle_info({shaper_expired, ?MODULE}, #state{sink=Sink, shaper=Shaper} = State) -> handle_info({shaper_expired, ?MODULE}, #state{sink=Sink, shaper=Shaper} = State) ->
?LOGFMT(Sink, warning, self(),
"lager_error_logger_h dropped ~p messages in the last second that exceeded the limit of ~p messages/sec",
[Shaper#lager_shaper.dropped, Shaper#lager_shaper.hwm]),
case Shaper#lager_shaper.dropped of
0 ->
ok;
Dropped ->
?LOGFMT(Sink, warning, self(),
"lager_error_logger_h dropped ~p messages in the last second that exceeded the limit of ~p messages/sec",
[Dropped, Shaper#lager_shaper.hwm])
end,
{ok, State#state{shaper=Shaper#lager_shaper{dropped=0, mps=1, lasttime=os:timestamp()}}}; {ok, State#state{shaper=Shaper#lager_shaper{dropped=0, mps=1, lasttime=os:timestamp()}}};
handle_info(_Info, State) -> handle_info(_Info, State) ->
{ok, State}. {ok, State}.

+ 11
- 6
src/lager_file_backend.erl ファイルの表示

@ -193,12 +193,17 @@ handle_info({rotate, File}, #state{name=File,count=Count,date=Date,rotator=Rotat
schedule_rotation(File, Date), schedule_rotation(File, Date),
{ok, State1}; {ok, State1};
handle_info({shaper_expired, Name}, #state{shaper=Shaper, name=Name, formatter=Formatter, formatter_config=FormatConfig} = State) -> handle_info({shaper_expired, Name}, #state{shaper=Shaper, name=Name, formatter=Formatter, formatter_config=FormatConfig} = State) ->
Report = io_lib:format(
"lager_file_backend dropped ~p messages in the last second that exceeded the limit of ~p messages/sec",
[Shaper#lager_shaper.dropped, Shaper#lager_shaper.hwm]),
ReportMsg = lager_msg:new(Report, warning, [], []),
write(State, lager_msg:timestamp(ReportMsg),
lager_msg:severity_as_int(ReportMsg), Formatter:format(ReportMsg, FormatConfig)),
case Shaper#lager_shaper.dropped of
0 ->
ok;
Dropped ->
Report = io_lib:format(
"lager_file_backend dropped ~p messages in the last second that exceeded the limit of ~p messages/sec",
[Dropped, Shaper#lager_shaper.hwm]),
ReportMsg = lager_msg:new(Report, warning, [], []),
write(State, lager_msg:timestamp(ReportMsg),
lager_msg:severity_as_int(ReportMsg), Formatter:format(ReportMsg, FormatConfig))
end,
{ok, State#state{shaper=Shaper#lager_shaper{dropped=0, mps=1, lasttime=os:timestamp()}}}; {ok, State#state{shaper=Shaper#lager_shaper{dropped=0, mps=1, lasttime=os:timestamp()}}};
handle_info(_Info, State) -> handle_info(_Info, State) ->
{ok, State}. {ok, State}.

読み込み中…
キャンセル
保存