@ -64,12 +64,32 @@ fmtCfg(MetaWhitelist) ->
[ datetime , sev , node , < < " | " > > , pid , < < " | " > > , module , < < " | " > > , function , < < " | " > > , line , < < " | " > > ] ++
[ { M , [ atom_to_binary ( M ) , < < " = " > > , M , " | " ] , [ < < > > ] } | | M < - MetaWhitelist ] ++ [ message , < < " \n " > > ] .
% % @ doc Print the format string ` Fmt ' with `Args' safely with a size
% % limit of ` Limit ' . If the format string is invalid , or not enough
% % arguments are supplied 'FORMAT ERROR' is printed with the offending
% % arguments . The caller is NOT crashed .
unsafeFormat ( Fmt , Args ) - >
try eFmt : formatIol ( Fmt , Args )
catch
_ : _ - > eFmt : formatIol ( < < " FORMAT ERROR SAFE: ~p ~p " > > , [ Fmt , Args ] )
end .
safeFormat ( Fmt , Args , Limit ) - >
try eFmt : formatIol ( Fmt , Args , Limit )
catch
_ : _ - >
eFmt : formatIol ( < < " FORMAT ERROR UNSAFE: ~p ~p " > > , [ Fmt , Args ] , Limit )
end .
% Level , Pid , Node , Module , Function , FunctionArity , Line
- define ( FixMd , [ pid , node , module , function , line ] ) .
- spec output ( term ( ) , lgMsg ( ) ) - > iolist ( ) .
output ( message , LgMsg ) - > LgMsg #lgMsg.message ;
output ( message , LgMsg ) - >
#lgMsg { msgFormat = Format , msgArgs = Args , msgSafety = Safety , msgFormatSize = Size } = LgMsg ,
? lgCASE ( Args =/= [ ] andalso Args =/= undefined , ? lgCASE ( Safety == safe , safeFormat ( Format , Args , [ { charsLimit , Size } ] ) , unsafeFormat ( Format , Args ) ) , Format ) ;
output ( datetime , LgMsg ) - > lgUtil : msToBinStr ( LgMsg #lgMsg.timestamp ) ;
output ( pid , LgMsg ) - > pid_to_list ( LgMsg #lgMsg.pid ) ;
output ( node , _ LgMsg ) - > ? eLogCfg : get ( ? eLogNodeName ) ;
@ -110,7 +130,9 @@ output({Prop, Present, Absent, Width}, LgMsg) when is_atom(Prop) ->
end ;
output ( Other , _ ) - > makeStr ( Other ) .
output ( message , LgMsg , _ Width ) - > LgMsg #lgMsg.message ;
output ( message , LgMsg , _ Width ) - >
#lgMsg { msgFormat = Format , msgArgs = Args , msgSafety = Safety , msgFormatSize = Size } = LgMsg ,
? lgCASE ( Args =/= [ ] andalso Args =/= undefined , ? lgCASE ( Safety == safe , safeFormat ( Format , Args , [ { charsLimit , Size } ] ) , unsafeFormat ( Format , Args ) ) , Format ) ;
output ( datetime , LgMsg , _ Width ) - > lgUtil : msToBinStr ( LgMsg #lgMsg.timestamp ) ;
output ( pid , LgMsg , _ Width ) - > pid_to_list ( LgMsg #lgMsg.pid ) ;
output ( node , _ LgMsg , _ Width ) - > ? eLogCfg : get ( ? eLogNodeName ) ;