Added a .env toggle for enabling/disabling detailed route logging
This commit is contained in:
parent
fa63bc7c24
commit
59f44e825a
2 changed files with 25 additions and 24 deletions
|
|
@ -272,8 +272,6 @@ module.exports = async (
|
|||
|
||||
app.use(async (req, res, next) => {
|
||||
try {
|
||||
logger.info("Route:", req.path)
|
||||
|
||||
if (unprotectedRoutes[req.method][req.path]) {
|
||||
next();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -195,31 +195,34 @@ const server = program => {
|
|||
})
|
||||
|
||||
app.use((req, res, next) => {
|
||||
if (sensitiveRoutes[req.method][req.path]) {
|
||||
logger.info(
|
||||
JSON.stringify({
|
||||
time: new Date(),
|
||||
ip: req.ip,
|
||||
method: req.method,
|
||||
path: req.path,
|
||||
sessionId: req.sessionId
|
||||
})
|
||||
)
|
||||
} else {
|
||||
logger.info(
|
||||
JSON.stringify({
|
||||
time: new Date(),
|
||||
ip: req.ip,
|
||||
method: req.method,
|
||||
path: req.path,
|
||||
body: req.body,
|
||||
query: req.query,
|
||||
sessionId: req.sessionId
|
||||
})
|
||||
)
|
||||
if (process.env.ROUTE_LOGGING === 'true') {
|
||||
if (sensitiveRoutes[req.method][req.path]) {
|
||||
logger.info(
|
||||
JSON.stringify({
|
||||
time: new Date(),
|
||||
ip: req.ip,
|
||||
method: req.method,
|
||||
path: req.path,
|
||||
sessionId: req.sessionId
|
||||
})
|
||||
)
|
||||
} else {
|
||||
logger.info(
|
||||
JSON.stringify({
|
||||
time: new Date(),
|
||||
ip: req.ip,
|
||||
method: req.method,
|
||||
path: req.path,
|
||||
body: req.body,
|
||||
query: req.query,
|
||||
sessionId: req.sessionId
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
app.use(
|
||||
session({
|
||||
secret: defaults.sessionSecret,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue