tera/Source/core/log-strict.js

39 lines
1020 B
JavaScript
Raw Normal View History

2019-02-10 19:53:54 +00:00
/*
* @project: TERA
* @version: Development (beta)
* @license: MIT (not for evil)
2019-03-16 16:08:05 +00:00
* @copyright: Yuriy Ivanov (Vtools) 2017-2019 [progr76@gmail.com]
2019-02-10 19:53:54 +00:00
* Web: https://terafoundation.org
* Twitter: https://twitter.com/terafoundation
* Telegram: https://web.telegram.org/#/im?p=@terafoundation
*/
var fs = require('fs');
function CheckSizeLogFile(file_name,file_name_prev)
{
"use strict";
let FILE_NAME_LOG = file_name;
let FILE_NAME_LOG_PREV = file_name_prev;
setInterval(function ()
{
try
{
var stat = fs.statSync(FILE_NAME_LOG);
if(stat.size > MAX_SIZE_LOG)
{
if(fs.existsSync(FILE_NAME_LOG_PREV))
{
fs.unlinkSync(FILE_NAME_LOG_PREV);
}
fs.renameSync(FILE_NAME_LOG, FILE_NAME_LOG_PREV);
ToLog("truncate logfile ok");
}
}
catch(err)
{
}
}, 60000);
};
global.CheckSizeLogFile = CheckSizeLogFile;