@@ -221,6 +221,7 @@ defmodule Logger do
221
221
"""
222
222
223
223
@ type backend :: GenEvent . handler
224
+ @ type message :: IO . chardata | String.Chars . t
224
225
@ type level :: :error | :info | :warn | :debug
225
226
@ levels [ :error , :info , :warn , :debug ]
226
227
@@ -367,7 +368,7 @@ defmodule Logger do
367
368
Use this function only when there is a need to log dynamically
368
369
or you want to explicitly avoid embedding metadata.
369
370
"""
370
- @ spec log ( level , IO . chardata | ( ( ) -> IO . chardata ) , Keyword . t ) ::
371
+ @ spec log ( level , message | ( ( ) -> message ) , Keyword . t ) ::
371
372
:ok | { :error , :noproc } | { :error , :timeout } | { :error , term }
372
373
def log ( level , chardata , metadata \\ [ ] ) when level in @ levels and is_list ( metadata ) do
373
374
% { mode: mode , truncate: truncate , timeout: timeout ,
@@ -458,6 +459,8 @@ defmodule Logger do
458
459
do: Logger.Utils . truncate ( data . ( ) , n )
459
460
defp truncate ( data , n ) when is_list ( data ) or is_binary ( data ) ,
460
461
do: Logger.Utils . truncate ( data , n )
462
+ defp truncate ( data , n ) ,
463
+ do: Logger.Utils . truncate ( to_string ( data ) , n )
461
464
462
465
defp notify ( :sync , msg , timeout ) , do: GenEvent . sync_notify ( Logger , msg , timeout )
463
466
defp notify ( :async , msg , _timeout ) , do: GenEvent . notify ( Logger , msg )
0 commit comments