mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Excluding things from request stats, script registering endpoint
This commit is contained in:
parent
b53fd84bf2
commit
f19226a74e
5 changed files with 87 additions and 9 deletions
|
@ -4,12 +4,14 @@ interface Options {
|
|||
loggableKeywords: Array<string>
|
||||
loggableModules: Array<string>
|
||||
exceptions: Array<string>
|
||||
excludeFromStats: Array<string>
|
||||
}
|
||||
|
||||
export default function(options: Options): any {
|
||||
const loggableKeywords = options ? options.loggableKeywords : undefined
|
||||
const loggableModules = options ? options.loggableModules : undefined
|
||||
const exceptions = options ? options.exceptions : []
|
||||
const exceptions = options.exceptions || []
|
||||
const excludeFromStats = options.excludeFromStats || []
|
||||
|
||||
return function(req, res, next) {
|
||||
res.on('finish', function() {
|
||||
|
@ -49,7 +51,12 @@ export default function(options: Options): any {
|
|||
if (toLog) {
|
||||
logger.LogReq(req)
|
||||
}
|
||||
if (res.statusCode !== 404) {
|
||||
|
||||
const shouldLogStat = !excludeFromStats.some((ex) => {
|
||||
return req.url.includes(ex)
|
||||
})
|
||||
|
||||
if (res.statusCode !== 404 && shouldLogStat) {
|
||||
logger.LogStat(
|
||||
req.url,
|
||||
ip,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue