@@ -175,8 +175,7 @@ defmodule Logger.Formatter do
175175 warning: Keyword . get ( colors , :warning , :yellow ) ,
176176 notice: Keyword . get ( colors , :info , :normal ) ,
177177 info: Keyword . get ( colors , :info , :normal ) ,
178- debug: Keyword . get ( colors , :debug , :cyan ) ,
179- enabled: Keyword . get ( colors , :enabled , IO.ANSI . enabled? ( ) )
178+ debug: Keyword . get ( colors , :debug , :cyan )
180179 }
181180 end
182181
@@ -222,11 +221,13 @@ defmodule Logger.Formatter do
222221
223222 defp format_fa ( fun , arity ) , do: [ Atom . to_string ( fun ) , "/" , Integer . to_string ( arity ) ]
224223
225- defp colorize ( data , _level , % { enabled: false } , _md ) , do: data
226-
227- defp colorize ( data , level , % { enabled: true } = colors , md ) do
228- color = md [ :ansi_color ] || Map . fetch! ( colors , level )
229- [ IO.ANSI . format_fragment ( color , true ) , data | IO.ANSI . reset ( ) ]
224+ defp colorize ( data , level , colors , md ) do
225+ if Map . get_lazy ( colors , :enabled , & IO.ANSI . enabled? / 0 ) do
226+ color = md [ :ansi_color ] || Map . fetch! ( colors , level )
227+ [ IO.ANSI . format_fragment ( color , true ) , data | IO.ANSI . reset ( ) ]
228+ else
229+ data
230+ end
230231 end
231232
232233 @ doc """
0 commit comments