mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 01:36:29 -05:00
feat(logging): Exclude /status route from logging
This patch should reduce the logging noise a lot, by removing the `/status` route from logging unless hedgedoc is running in debug mode or the route throws an error code. This is achieved by providing a "skip"-function to the morgan logging provider. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
This commit is contained in:
parent
6c17823da1
commit
add5d998c0
2 changed files with 7 additions and 0 deletions
6
app.js
6
app.js
|
@ -65,6 +65,12 @@ if (!config.useSSL && config.protocolUseSSL) {
|
||||||
|
|
||||||
// logger
|
// logger
|
||||||
app.use(morgan('combined', {
|
app.use(morgan('combined', {
|
||||||
|
skip: function(req, res) {
|
||||||
|
// skip logging if specified
|
||||||
|
// unless the app is running in debug mode
|
||||||
|
// or throws an error
|
||||||
|
return req.skipLogging && config.loglevel !== "debug" && res.statusCode < 400
|
||||||
|
},
|
||||||
stream: logger.stream
|
stream: logger.stream
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ const statusRouter = module.exports = Router()
|
||||||
|
|
||||||
// get status
|
// get status
|
||||||
statusRouter.get('/status', function (req, res, next) {
|
statusRouter.get('/status', function (req, res, next) {
|
||||||
|
req.skipLogging = true
|
||||||
realtime.getStatus(function (data) {
|
realtime.getStatus(function (data) {
|
||||||
res.set({
|
res.set({
|
||||||
'Cache-Control': 'private', // only cache by client
|
'Cache-Control': 'private', // only cache by client
|
||||||
|
|
Loading…
Reference in a new issue