mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Prettied some stuff, and moved submodules around again
This commit is contained in:
parent
d8ef7cdcb0
commit
3f081d8dff
6 changed files with 106 additions and 182 deletions
|
@ -1,11 +1,11 @@
|
|||
const logger = require('../utils/logger.js')
|
||||
|
||||
module.exports = function (options) {
|
||||
module.exports = function(options) {
|
||||
const loggableKeywords = options ? options.loggableKeywords : undefined
|
||||
const loggableModules = options ? options.loggableModules : undefined
|
||||
|
||||
return function (req, res, next) {
|
||||
res.on('finish', function () {
|
||||
return function(req, res, next) {
|
||||
res.on('finish', function() {
|
||||
if (req.url.includes('_next/static')) {
|
||||
return
|
||||
}
|
||||
|
@ -22,18 +22,25 @@ module.exports = function (options) {
|
|||
}
|
||||
|
||||
// fixme: regexp includes checking
|
||||
const hasLoggableKeyword = loggableKeywords && loggableKeywords.some((x) => {
|
||||
return req.url.includes(x)
|
||||
})
|
||||
const hasLoggableModule = loggableModules && loggableModules.some((x) => {
|
||||
return hostname.includes(x)
|
||||
})
|
||||
const hasLoggableKeyword =
|
||||
loggableKeywords &&
|
||||
loggableKeywords.some((x) => {
|
||||
return req.url.includes(x)
|
||||
})
|
||||
const hasLoggableModule =
|
||||
loggableModules &&
|
||||
loggableModules.some((x) => {
|
||||
return hostname.includes(x)
|
||||
})
|
||||
const toLog = hasLoggableModule || hasLoggableKeyword
|
||||
|
||||
logger.LogReq(req, true, res.statusCode)
|
||||
if (toLog) { logger.LogReq(req) }
|
||||
if (toLog) {
|
||||
logger.LogReq(req)
|
||||
}
|
||||
if (res.statusCode !== 404) {
|
||||
logger.LogStat(req.url,
|
||||
logger.LogStat(
|
||||
req.url,
|
||||
ip,
|
||||
hostname,
|
||||
req.session && req.session.user ? req.session.user.id : 'NOUSER'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue