|
|
@ -48,7 +48,7 @@ |
|
|
|
checkInterval = ?RumDefCheckInterval :: non_neg_integer(), %% 单位毫秒 |
|
|
|
syncInterval = ?RumDefSyncInterval :: non_neg_integer(), |
|
|
|
syncSize = ?RumDefSyncSize :: non_neg_integer(), |
|
|
|
lastCheck = os:timestamp() :: erlang:timestamp(), %% 单位毫秒 |
|
|
|
lastCheck = rumTime:nowMs() :: erlang:timestamp(), %% 单位毫秒 |
|
|
|
osType :: atom() |
|
|
|
}). |
|
|
|
|
|
|
@ -176,12 +176,12 @@ terminate(_Reason, State) -> |
|
|
|
code_change(_OldVsn, State, _Extra) -> |
|
|
|
{ok, State}. |
|
|
|
|
|
|
|
writeLog(#state{fileName = FileName, fd = Fd, inode = Inode, ctime = Ctime, flap = Flap, size = RotSize, count = Count, rotator = Rotator, lastCheck = LastCheck, checkInterval = CheckInterval, syncSize = SyncSize, syncInterval = SyncInterval} = State, Timestamp, Level, Msg) -> |
|
|
|
case isWriteCheck(Fd, LastCheck, CheckInterval, FileName, Inode, Ctime, Timestamp) of |
|
|
|
writeLog(#state{fileName = FileName, fd = Fd, inode = Inode, ctime = CTime, flap = Flap, size = RotSize, count = Count, rotator = Rotator, lastCheck = LastCheck, checkInterval = CheckInterval, syncSize = SyncSize, syncInterval = SyncInterval} = State, Timestamp, Level, Msg) -> |
|
|
|
case isWriteCheck(Fd, LastCheck, CheckInterval, FileName, Inode, CTime, Timestamp) of |
|
|
|
true -> |
|
|
|
%% need to check for rotation |
|
|
|
case Rotator:ensureLogFile(FileName, Fd, Inode, Ctime, {SyncSize, SyncInterval}) of |
|
|
|
{ok, NewFD, NewInode, NewCtime, FileSize} -> |
|
|
|
case Rotator:ensureLogFile(FileName, Fd, Inode, CTime, {SyncSize, SyncInterval}) of |
|
|
|
{ok, NewFD, NewInode, NewCTime, FileSize} -> |
|
|
|
case RotSize > 0 andalso FileSize > RotSize of |
|
|
|
true -> |
|
|
|
TemState = closeFile(State), |
|
|
@ -194,7 +194,7 @@ writeLog(#state{fileName = FileName, fd = Fd, inode = Inode, ctime = Ctime, flap |
|
|
|
end; |
|
|
|
_ -> |
|
|
|
%% update our last check and try again |
|
|
|
TemState = State#state{lastCheck = Timestamp, fd = NewFD, inode = NewInode, ctime = NewCtime}, |
|
|
|
TemState = State#state{lastCheck = Timestamp, fd = NewFD, inode = NewInode, ctime = NewCTime}, |
|
|
|
writeFile(TemState, Level, Msg) |
|
|
|
end; |
|
|
|
{error, Reason} -> |
|
|
|