소스 검색

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
No known key found for this signature in database 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.
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()}}};
handle_info(_Info, 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),
{ok, State1};
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()}}};
handle_info(_Info, State) ->
{ok, State}.

불러오는 중...
취소
저장