|
@ -60,10 +60,10 @@ init(Opts) -> |
|
|
Count = rumUtil:get_opt(count, Opts, ?RumDefRotateCnt), |
|
|
Count = rumUtil:get_opt(count, Opts, ?RumDefRotateCnt), |
|
|
Rotator = rumUtil:get_opt(rotator, Opts, ?RumDefRotateMod), |
|
|
Rotator = rumUtil:get_opt(rotator, Opts, ?RumDefRotateMod), |
|
|
HWM = rumUtil:get_opt(hWM, Opts, ?RumDefCheckHWM), |
|
|
HWM = rumUtil:get_opt(hWM, Opts, ?RumDefCheckHWM), |
|
|
Flush = rumUtil:get_opt(flushQueue, Opts, ?RumDefFlushQueue), |
|
|
|
|
|
|
|
|
FlushQueue = rumUtil:get_opt(flushQueue, Opts, ?RumDefFlushQueue), |
|
|
FlushThr = rumUtil:get_opt(flushThr, Opts, ?RumDefFlushThr), |
|
|
FlushThr = rumUtil:get_opt(flushThr, Opts, ?RumDefFlushThr), |
|
|
SyncInt = rumUtil:get_opt(syncInt, Opts, ?RumDefSyncInt), |
|
|
SyncInt = rumUtil:get_opt(syncInt, Opts, ?RumDefSyncInt), |
|
|
CfgCheckInterval = rumUtil:get_opt(checkInt, Opts, ?RumDefCheckInt), |
|
|
|
|
|
|
|
|
CfgCheckInt = rumUtil:get_opt(checkInt, Opts, ?RumDefCheckInt), |
|
|
SyncSize = rumUtil:get_opt(syncSize, Opts, ?RumDefSyncSize), |
|
|
SyncSize = rumUtil:get_opt(syncSize, Opts, ?RumDefSyncSize), |
|
|
CfgSyncOn = rumUtil:get_opt(syncOn, Opts, ?RumDefSyncLevel), |
|
|
CfgSyncOn = rumUtil:get_opt(syncOn, Opts, ?RumDefSyncLevel), |
|
|
FormatTer = rumUtil:get_opt(formatTer, Opts, ?RumDefFormatTer), |
|
|
FormatTer = rumUtil:get_opt(formatTer, Opts, ?RumDefFormatTer), |
|
@ -72,7 +72,7 @@ init(Opts) -> |
|
|
%% 需要二次转换的配置在这里处理 |
|
|
%% 需要二次转换的配置在这里处理 |
|
|
Level = rumUtil:configToMask(CfgLevel), |
|
|
Level = rumUtil:configToMask(CfgLevel), |
|
|
SyncOn = rumUtil:configToMask(CfgSyncOn), |
|
|
SyncOn = rumUtil:configToMask(CfgSyncOn), |
|
|
CheckInt = ?IIF(CfgCheckInterval == always, 0, CfgCheckInterval), |
|
|
|
|
|
|
|
|
CheckInt = ?IIF(CfgCheckInt == always, 0, CfgCheckInt), |
|
|
{ok, Date} = rumUtil:parseRotateSpec(CfgDate), |
|
|
{ok, Date} = rumUtil:parseRotateSpec(CfgDate), |
|
|
FileName = rumUtil:parsePath(RelName), |
|
|
FileName = rumUtil:parsePath(RelName), |
|
|
|
|
|
|
|
@ -86,7 +86,7 @@ init(Opts) -> |
|
|
end, |
|
|
end, |
|
|
|
|
|
|
|
|
scheduleRotation(Date, FileName), |
|
|
scheduleRotation(Date, FileName), |
|
|
Shaper = rumUtil:maybeFlush(Flush, #rumShaper{hwm = HWM, flushThr = FlushThr, id = FileName}), |
|
|
|
|
|
|
|
|
Shaper = #rumShaper{hwm = HWM, flushQueue = FlushQueue, flushThr = FlushThr, id = FileName}, |
|
|
TemState = #state{ |
|
|
TemState = #state{ |
|
|
fileName = FileName, level = Level, size = Size, date = Date |
|
|
fileName = FileName, level = Level, size = Size, date = Date |
|
|
, count = Count, rotator = Rotator, shaper = Shaper |
|
|
, count = Count, rotator = Rotator, shaper = Shaper |
|
@ -237,9 +237,9 @@ writeFile(#state{fd = Fd, fileName = FileName, flap = Flap, syncOn = SyncOn} = S |
|
|
State |
|
|
State |
|
|
end. |
|
|
end. |
|
|
|
|
|
|
|
|
isWriteCheck(Fd, LastCheck, CheckInterval, Name, Inode, CTime, Timestamp) -> |
|
|
|
|
|
|
|
|
isWriteCheck(Fd, LastCheck, CheckInt, Name, Inode, CTime, Timestamp) -> |
|
|
DiffTime = abs(Timestamp - LastCheck), |
|
|
DiffTime = abs(Timestamp - LastCheck), |
|
|
case DiffTime >= CheckInterval orelse Fd == undefined of |
|
|
|
|
|
|
|
|
case DiffTime >= CheckInt orelse Fd == undefined of |
|
|
true -> |
|
|
true -> |
|
|
true; |
|
|
true; |
|
|
_ -> |
|
|
_ -> |
|
@ -250,11 +250,16 @@ isWriteCheck(Fd, LastCheck, CheckInterval, Name, Inode, CTime, Timestamp) -> |
|
|
|
|
|
|
|
|
%% Convert the config into a gen_event handler ID |
|
|
%% Convert the config into a gen_event handler ID |
|
|
configToId(Config) -> |
|
|
configToId(Config) -> |
|
|
case rumUtil:get_opt(file, Config, undefined) of |
|
|
|
|
|
|
|
|
case rumUtil:get_opt(id, Config, undefined) of |
|
|
undefined -> |
|
|
undefined -> |
|
|
erlang:error(no_file); |
|
|
|
|
|
File -> |
|
|
|
|
|
{?MODULE, File} |
|
|
|
|
|
|
|
|
case rumUtil:get_opt(file, Config, undefined) of |
|
|
|
|
|
undefined -> |
|
|
|
|
|
erlang:error(no_file); |
|
|
|
|
|
File -> |
|
|
|
|
|
{?MODULE, File} |
|
|
|
|
|
end; |
|
|
|
|
|
Id -> |
|
|
|
|
|
{?MODULE, Id} |
|
|
end. |
|
|
end. |
|
|
|
|
|
|
|
|
checkOpts([], IsFile) -> |
|
|
checkOpts([], IsFile) -> |
|
|