mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Added logrotate #7
This commit is contained in:
parent
f1f7b86fea
commit
756d22e535
3 changed files with 28 additions and 12 deletions
|
@ -16,6 +16,6 @@ module.exports = {
|
|||
eqeqeq: ['warn', 'smart'],
|
||||
'no-unused-vars': 'warn',
|
||||
'no-prototype-builtins': 'off',
|
||||
'id-length': ['warn', { exceptions: ['i', 'j', 't', 'Q', 'A'] }],
|
||||
'id-length': ['warn', { exceptions: ['i', 'j', 't', 'Q', 'A', 'C'] }],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -250,6 +250,7 @@ function LogTimerAction() {
|
|||
const line =
|
||||
'==================================================================================================================================================='
|
||||
logger.Log(line)
|
||||
logger.setNewLogfileName()
|
||||
utils.AppendToFile(line, locLogFile)
|
||||
utils.AppendToFile(line, allLogFile)
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@ module.exports = {
|
|||
logHashed: logHashed,
|
||||
hr: hr,
|
||||
C: C,
|
||||
setNewLogfileName,
|
||||
}
|
||||
|
||||
const DELIM = C('green') + '|' + C()
|
||||
|
||||
const utils = require('../utils/utils.js')
|
||||
const locLogFile = './stats/logs'
|
||||
const logFile = '/nlogs/nlogs'
|
||||
const allLogFile = '/nlogs/log'
|
||||
const vlogDir = './stats/vlogs/'
|
||||
const logDir = './stats/logs/'
|
||||
const statFile = 'stats/stats'
|
||||
const vStatFile = 'stats/vstats'
|
||||
const uStatsFile = 'stats/ustats'
|
||||
|
@ -47,6 +47,7 @@ const uvStatsFile = 'stats/uvstats'
|
|||
const nologFile = './nolog'
|
||||
|
||||
const colors = ['green', 'red', 'yellow', 'blue', 'magenta', 'cyan']
|
||||
let logFileName = getDayString()
|
||||
|
||||
const writeInterval = 10
|
||||
const debugLevel = parseInt(process.env.NS_LOGLEVEL) || 0
|
||||
|
@ -60,10 +61,25 @@ let writes = 0
|
|||
|
||||
let noLogips = []
|
||||
|
||||
function setNewLogfileName() {
|
||||
logFileName = getDayString()
|
||||
}
|
||||
|
||||
function getDayString() {
|
||||
const date = new Date()
|
||||
return (
|
||||
date.getFullYear() +
|
||||
'_' +
|
||||
('0' + (date.getMonth() + 1)).slice(-2) +
|
||||
'_' +
|
||||
('0' + date.getDate()).slice(-2)
|
||||
)
|
||||
}
|
||||
|
||||
function GetDateString() {
|
||||
const m = new Date()
|
||||
const d = utils.GetDateString()
|
||||
return GetRandomColor(m.getHours().toString()) + d + C()
|
||||
const date = new Date()
|
||||
const dateString = utils.GetDateString()
|
||||
return GetRandomColor(date.getHours().toString()) + dateString + C()
|
||||
}
|
||||
|
||||
function DebugLog(msg, name, lvl) {
|
||||
|
@ -93,7 +109,7 @@ function Log(s, c) {
|
|||
}
|
||||
|
||||
console.log(log)
|
||||
utils.AppendToFile(log, logFile)
|
||||
utils.AppendToFile(log, logDir + logFileName)
|
||||
}
|
||||
|
||||
function LogReq(req, toFile, sc) {
|
||||
|
@ -146,11 +162,10 @@ function LogReq(req, toFile, sc) {
|
|||
} else {
|
||||
let defLogs = GetDateString() + dl + logEntry
|
||||
|
||||
utils.AppendToFile(defLogs, locLogFile)
|
||||
utils.AppendToFile(defLogs, allLogFile)
|
||||
utils.AppendToFile(defLogs, vlogDir + logFileName)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
Log('Error at logging lol', GetColor('redbg'), true)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue