mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Not logging nolog ip stats
This commit is contained in:
parent
5dfcb7d8ae
commit
34d7185736
2 changed files with 10 additions and 2 deletions
|
@ -66,12 +66,13 @@ const app = express()
|
||||||
|
|
||||||
app.use(function (req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
res.on('finish', function () {
|
res.on('finish', function () {
|
||||||
|
let ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
|
||||||
logger.LogReq(req, true, res.statusCode)
|
logger.LogReq(req, true, res.statusCode)
|
||||||
let toLog = loggableKeywords.some((x) => {
|
let toLog = loggableKeywords.some((x) => {
|
||||||
return req.url.includes(x)
|
return req.url.includes(x)
|
||||||
})
|
})
|
||||||
if (toLog) { logger.LogReq(req) }
|
if (toLog) { logger.LogReq(req) }
|
||||||
if (res.statusCode !== 404) { logger.LogStat(req.url) }
|
if (res.statusCode !== 404) { logger.LogStat(req.url, ip) }
|
||||||
})
|
})
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
|
@ -138,7 +138,14 @@ function Load () {
|
||||||
setNoLogReadInterval()
|
setNoLogReadInterval()
|
||||||
}
|
}
|
||||||
|
|
||||||
function LogStat (url) {
|
function LogStat (url, ip) {
|
||||||
|
let nolog = noLogips.some((x) => {
|
||||||
|
return x.includes(ip)
|
||||||
|
})
|
||||||
|
if (nolog) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
url = url.split('?')[0]
|
url = url.split('?')[0]
|
||||||
Inc(url)
|
Inc(url)
|
||||||
AddVisitStat(url)
|
AddVisitStat(url)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue