@ -138,7 +138,7 @@ handleEvent({mWriteLog, Message}, #state{fBName = _FBName, level = Level, shaper
_ - >
ReportStr = eFmt : format ( < < " lgBkdFile dropped ~p messages in the last second that exceeded the limit of ~p messages/sec " > > , [ Drop , NewShaper #lgShaper.hwm ] ) ,
NowMs = lgTime : nowMs ( ) ,
ReportMsg = #lgMsg { severity = ? llvWarning , pid = self ( ) , node = node ( ) , module = ? MODULE , function = ? FUNCTION_NAME , line = ? LINE , metadata = [ ] , timestamp = NowMs , message = ReportStr , destinations = [ ] } ,
ReportMsg = #lgMsg { severity = ? llvWarning , pid = self ( ) , module = ? MODULE , function = ? FUNCTION_NAME , line = ? LINE , metadata = [ ] , timestamp = NowMs , message = ReportStr , destinations = [ ] } ,
writeLog ( State , NowMs , ? llvWarning , FmtTer : format ( ReportMsg , FmtCfg ) )
end ,
{ noreply , writeLog ( TemState #state { shaper = NewShaper } , Timestamp , Severity , FmtTer : format ( Message , FmtCfg ) ) } ;
@ -165,7 +165,7 @@ handleInfo({mShaperExpired, FBName}, #state{shaper = Shaper, fBName = FBName, fm
Dropped - >
ReportStr = eFmt : format ( < < " lgBkdFile dropped ~p messages in the last second that exceeded the limit of ~p messages/sec " > > , [ Dropped , Shaper #lgShaper.hwm ] ) ,
NowMs = lgTime : nowMs ( ) ,
ReportMsg = #lgMsg { severity = ? llvWarning , pid = self ( ) , node = node ( ) , module = ? MODULE , function = ? FUNCTION_NAME , line = ? LINE , metadata = [ ] , timestamp = NowMs , message = ReportStr , destinations = [ ] } ,
ReportMsg = #lgMsg { severity = ? llvWarning , pid = self ( ) , module = ? MODULE , function = ? FUNCTION_NAME , line = ? LINE , metadata = [ ] , timestamp = NowMs , message = ReportStr , destinations = [ ] } ,
writeLog ( State , NowMs , ? llvWarning , FmtTer : format ( ReportMsg , FmtCfg ) )
end ,
{ noreply , State #state { shaper = Shaper #lgShaper { dropped = 0 } } } ;
@ -184,6 +184,7 @@ code_change(_OldVsn, State, _Extra) ->
writeLog ( #state { fileName = FileName , fd = Fd , inode = Inode , cTime = CTime , flap = Flap , size = RotSize , rotator = Rotator , lastCheck = LastCheck , checkInt = CheckInt , syncSize = SyncSize , syncInt = SyncInt } = State , Timestamp , Level , Msg ) - >
case isWriteCheck ( Fd , LastCheck , CheckInt , FileName , Inode , CTime , Timestamp ) of
true - >
io : format ( " IMY****************111 ~p ~p ~p ~n " , [ Fd , CheckInt , Timestamp ] ) ,
% % need to check for rotation
case Rotator : ensureLogFile ( FileName , Fd , Inode , CTime , { SyncSize , SyncInt } ) of
{ ok , NewFD , NewInode , NewCTime , FileSize } - >
@ -201,6 +202,7 @@ writeLog(#state{fileName = FileName, fd = Fd, inode = Inode, cTime = CTime, flap
? lgCASE ( Flap , State , begin ? INT_LOG ( ? llvError , < < " Failed to reopen log file ~ ts with error ~s " > > , [ FileName , file : format_error ( Reason ) ] ) , State #state { flap = true } end )
end ;
_ - >
io : format ( " IMY***************222 ~p ~p ~p ~n " , [ Fd , CheckInt , Timestamp ] ) ,
writeFile ( State , Level , Msg )
end .
@ -225,15 +227,17 @@ writeFile(#state{fd = Fd, fileName = FileName, flap = Flap, syncOn = SyncOn} = S
State
end .
isWriteCheck ( Fd , LastCheck , CheckInt , Name , Inode , CTime , Timestamp ) - >
isWriteCheck ( undefined , _ LastCheck , _ CheckInt , _ Name , _ Inode , _ CTime , _ Timestamp ) - >
true ;
isWriteCheck ( _ Fd , LastCheck , CheckInt , Name , Inode , CTime , Timestamp ) - >
DiffTime = abs ( Timestamp - LastCheck ) ,
case DiffTime > = CheckInt orelse Fd == undefined of
case DiffTime > = CheckInt of
true - >
true ;
_ - >
% We need to know if the file has changed " out from under eLog " so we don ' t write to an invalid Fd
{ Result , _ FInfo } = lgUtil : isFileChanged ( Name , Inode , CTime ) ,
Result
Result ;
_ - >
false
end .
% % Convert the config into a gen_event handler ID