@ -123,20 +123,23 @@ handleCall(_Msg, State) ->
handleEvent ( { mWriteLog , Message } , #state { fileName = FileName , level = Level , shaper = Shaper , formatTer = FormatTer , formatCfg = FormatCfg } = State ) - >
case rumUtil : isLoggAble ( Message , Level , { rumBkdFile , FileName } ) of
true - >
#rumMsg { timestamp = Timestamp , severity = Severity } = Message ,
case rumUtil : checkHwm ( Shaper ) of
{ true , _ Drop , NewShaper } - >
{ ok , writeLog ( State #state { shaper = NewShaper } , rumMsg : timestamp ( Message ) , rumMsg : severity_as_int ( Message ) , FormatTer : format ( Message , FormatCfg ) ) } ;
{ ok , writeLog ( State #state { shaper = NewShaper } , Timestamp , Severity , FormatTer : format ( Message , FormatCfg ) ) } ;
{ drop , Drop , NewShaper } - >
TemState =
case Drop =< 0 of
true - >
State ;
_ - >
Report = eFmt : format ( < < " rumBkdFile dropped ~p messages in the last second that exceeded the limit of ~p messages/sec " > > , [ Drop , NewShaper #rumShaper.hwm ] ) ,
ReportMsg = rumMsg : new ( Report , warning , [ ] , [ ] ) ,
writeLog ( State , rumMsg : timestamp ( ReportMsg ) , rumMsg : severity_as_int ( ReportMsg ) , FormatTer : format ( ReportMsg , FormatCfg ) )
ReportStr = eFmt : format ( < < " rumBkdFile dropped ~p messages in the last second that exceeded the limit of ~p messages/sec " > > , [ Drop , NewShaper #rumShaper.hwm ] ) ,
NowMs = rumTime : nowMs ( ) ,
NowStr = rumUtil : msToBinStr ( NowMs ) ,
ReportMsg = #rumMsg { severity = ? warning , pid = self ( ) , node = node ( ) , module = ? MODULE , function = ? FUNCTION_NAME , line = ? LINE , metadata = [ ] , datetime = NowStr , timestamp = NowMs , message = ReportStr , destinations = [ ] } ,
writeLog ( State , NowMs , ? warning , FormatTer : format ( ReportMsg , FormatCfg ) )
end ,
{ ok , writeLog ( TemState #state { shaper = NewShaper } , rumMsg : timestamp ( Message ) , rumMsg : severity_as_int ( Message ) , FormatTer : format ( Message , FormatCfg ) ) } ;
{ ok , writeLog ( TemState #state { shaper = NewShaper } , Timestamp , Severity , FormatTer : format ( Message , FormatCfg ) ) } ;
{ false , _ , NewShaper } - >
{ ok , State #state { shaper = NewShaper } }
end ;
@ -157,9 +160,11 @@ handleInfo({mShaperExpired, Name}, #state{shaper = Shaper, fileName = Name, form
0 - >
ignore ;
Dropped - >
Report = eFmt : format ( < < " rumBkdFile dropped ~p messages in the last second that exceeded the limit of ~p messages/sec " > > , [ Dropped , Shaper #rumShaper.hwm ] ) ,
ReportMsg = rumMsg : new ( Report , warning , [ ] , [ ] ) ,
writeLog ( State , rumMsg : timestamp ( ReportMsg ) , rumMsg : severity_as_int ( ReportMsg ) , FormatTer : format ( ReportMsg , FormatCfg ) )
ReportStr = eFmt : format ( < < " rumBkdFile dropped ~p messages in the last second that exceeded the limit of ~p messages/sec " > > , [ Dropped , Shaper #rumShaper.hwm ] ) ,
NowMs = rumTime : nowMs ( ) ,
NowStr = rumUtil : msToBinStr ( NowMs ) ,
ReportMsg = #rumMsg { severity = ? warning , pid = self ( ) , node = node ( ) , module = ? MODULE , function = ? FUNCTION_NAME , line = ? LINE , metadata = [ ] , datetime = NowStr , timestamp = NowMs , message = ReportStr , destinations = [ ] } ,
writeLog ( State , NowMs , ? warning , FormatTer : format ( ReportMsg , FormatCfg ) )
end ,
{ ok , State #state { shaper = Shaper #rumShaper { dropped = 0 , mps = 0 , lastTime = rumTime : now ( ) } } } ;
handleInfo ( _ Msg , _ State ) - >