From 985612f1679aad1ad9f6122e8553a595fc04b82c Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Fri, 19 Jan 2018 10:40:23 -0800 Subject: [PATCH] Make a few corrections to the recent mailbox flushing changes --- src/error_logger_lager_h.erl | 2 +- src/lager_util.erl | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/error_logger_lager_h.erl b/src/error_logger_lager_h.erl index bd7b679..3755a1d 100644 --- a/src/error_logger_lager_h.erl +++ b/src/error_logger_lager_h.erl @@ -72,7 +72,7 @@ set_high_water(N) -> -spec init(any()) -> {ok, #state{}}. init([HighWaterMark, GlStrategy]) -> - Flush = application:get_env(lager, error_logger_flush_queue, false), + Flush = application:get_env(lager, error_logger_flush_queue, true), FlushThr = application:get_env(lager, error_logger_flush_threshold, 0), Shaper = #lager_shaper{hwm=HighWaterMark, flush_queue = Flush, flush_threshold = FlushThr, filter=shaper_fun(), id=?MODULE}, Raw = application:get_env(lager, error_logger_format_raw, false), diff --git a/src/lager_util.erl b/src/lager_util.erl index 87729b5..26c24c2 100644 --- a/src/lager_util.erl +++ b/src/lager_util.erl @@ -515,7 +515,7 @@ check_hwm(Shaper = #lager_shaper{lasttime = Last, dropped = Drop}) -> true -> discard_messages(Now, Shaper#lager_shaper.filter, 0); false -> - 1 + 0 end, Timer = case erlang:read_timer(Shaper#lager_shaper.timer) of false -> @@ -534,7 +534,9 @@ should_flush(#lager_shaper{flush_queue = true, flush_threshold = 0}) -> true; should_flush(#lager_shaper{flush_queue = true, flush_threshold = T}) -> {_, L} = process_info(self(), message_queue_len), - L > T. + L > T; +should_flush(_) -> + false. discard_messages(Second, Filter, Count) -> {M, S, _} = os:timestamp(),