Skip to content

Commit

Permalink
chore(fe2): reducing log level for some spammy req logs (#1954)
Browse files Browse the repository at this point in the history
* chore(fe2): reducing log level for some spammy req logs

* minor adjustment

* more robust path resolution
  • Loading branch information
fabis94 authored Jan 11, 2024
1 parent 6d65ec4 commit c6a821e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/frontend-2/server/middleware/001-logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,23 @@ export const LoggingMiddleware = pinoHttp({
// and we don't really care about 3xx stuff
// all the user related 4xx responses are treated as info
customLogLevel: (
_: IncomingMessage,
req: IncomingMessage,
res: ServerResponse,
error: Error | undefined
) => {
// Mark some lower importance/spammy endpoints w/ 'debug' to reduce noise
const path = req.url?.split('?')[0]
const shouldBeDebug = ['/metrics', '/health'].includes(path || '') ?? false

if (res.statusCode >= 400 && res.statusCode < 500) {
return 'info'
} else if (res.statusCode >= 500 || error) {
return 'error'
} else if (res.statusCode >= 300 && res.statusCode < 400) {
return 'silent'
}
return 'info'

return shouldBeDebug ? 'debug' : 'info'
},

customSuccessMessage(req, res) {
Expand Down

0 comments on commit c6a821e

Please sign in to comment.