@@ -5,8 +5,6 @@ defmodule Logger.Config do
55 @ name __MODULE__
66 @ update_counter_message { __MODULE__ , :update_counter }
77
8- alias Logger.Counter
9-
108 def configure ( options ) do
119 :gen_event . call ( Logger , @ name , { :configure , options } )
1210 end
@@ -76,6 +74,8 @@ defmodule Logger.Config do
7674 { :ok , state }
7775 end
7876
77+ @ counter_pos 1
78+
7979 defp update_counter ( { counter , log , discard_threshold , discard_period } , periodic_check? ) do
8080 # If length is more than the total, it means the counter is behind,
8181 # due to non-log messages, so we need to increase the counter.
@@ -88,9 +88,9 @@ defmodule Logger.Config do
8888 # deliver the message yet. Those bumps will be lost. At the same time,
8989 # we are careful to read the counter first here, so if the counter is
9090 # bumped after we read from it, those bumps won't be lost.
91- total = Counter . read ( counter )
91+ total = :counters . get ( counter , @ counter_pos )
9292 { :message_queue_len , length } = Process . info ( self ( ) , :message_queue_len )
93- Counter . add ( counter , length - total )
93+ :counters . add ( counter , @ counter_pos , length - total )
9494
9595 # In case we are logging but we reached the threshold, we log that we
9696 # started discarding messages. This can only be reverted by the periodic
@@ -128,7 +128,6 @@ defmodule Logger.Config do
128128 { :ok , % { config: data } } = :logger . get_handler_config ( Logger )
129129 translators = fun . ( data . translators )
130130 Application . put_env ( :logger , :translators , translators )
131- # TODO: Use update_handler_config on Erlang/OTP 22+.
132- :ok = :logger . set_handler_config ( Logger , :config , % { data | translators: translators } )
131+ :ok = :logger . update_handler_config ( Logger , :config , translators: translators )
133132 end
134133end
0 commit comments