mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
moving log file if its not from today
This commit is contained in:
parent
2d6baa2549
commit
28af84148e
2 changed files with 35 additions and 0 deletions
|
@ -51,6 +51,22 @@ const usersDBPath = './data/dbs/users.db'
|
|||
const logFile = logger.logDir + logger.logFileName
|
||||
const vlogFile = logger.vlogDir + logger.logFileName
|
||||
|
||||
function moveLogIfNotFromToday(path, to) {
|
||||
if (utils.FileExists(path)) {
|
||||
const today = new Date()
|
||||
const stat = utils.statFile(path)
|
||||
if (
|
||||
today.getFullYear() !== stat.mtime.getFullYear() ||
|
||||
today.getMonth() !== stat.mtime.getMonth() ||
|
||||
today.getDate() !== stat.mtime.getDate()
|
||||
) {
|
||||
utils.renameFile(path, to + utils.GetDateString(stat.mtime))
|
||||
}
|
||||
}
|
||||
}
|
||||
moveLogIfNotFromToday(logFile, logger.logDir)
|
||||
moveLogIfNotFromToday(vlogFile, logger.vlogDir)
|
||||
|
||||
idStats.Load()
|
||||
logger.Load()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue