diff options
Diffstat (limited to 'lib/logger/test/logger_test.exs')
-rw-r--r-- | lib/logger/test/logger_test.exs | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/logger/test/logger_test.exs b/lib/logger/test/logger_test.exs index 038f86851..9a22b7da3 100644 --- a/lib/logger/test/logger_test.exs +++ b/lib/logger/test/logger_test.exs @@ -442,16 +442,23 @@ defmodule LoggerTest do test "logs when discarding messages" do assert :ok = Logger.configure(discard_threshold: 5) - assert capture_log(fn -> - :sys.suspend(Logger) - - for _ <- 1..10 do - Logger.warn("warning!") - end - - :sys.resume(Logger) - Logger.flush() - end) =~ ~r"Attempted to log \d+ messages, which is above :discard_threshold" + log = + capture_log(fn -> + :sys.suspend(Logger) + for _ <- 1..10, do: Logger.warn("warning!") + :sys.resume(Logger) + Logger.flush() + + # This is a private message but the simplest way to test this functionality + send(Logger, {Logger.Config, :update_counter}) + + # We need to flush twice. Once for the send and another for the log in send + Logger.flush() + Logger.flush() + end) + + assert log =~ ~r"\[warn\] Attempted to log \d+ messages, which is above :discard_threshold" + assert log =~ ~r"\[warn\] Attempted to log \d+ messages, which is below :discard_threshold" after :sys.resume(Logger) assert :ok = Logger.configure(discard_threshold: 500) |