Merge pull request #4760 from specklesystems/iain/express-no-log-graphql
chore(server/logging): do not log requests to Express if logged by Apollo middleware
This commit is contained in:
@@ -50,14 +50,23 @@ export const sanitizeQueryParams = (
|
||||
return query
|
||||
}
|
||||
|
||||
const shouldBeLoggedAsDebug = (req: IncomingMessage) => {
|
||||
const path = getRequestPath(req)
|
||||
if (!path) return false
|
||||
return [
|
||||
'/metrics',
|
||||
'/readiness',
|
||||
'/liveness',
|
||||
'/graphql' // graphql endpoint is logged by the graphql middleware
|
||||
].includes(path)
|
||||
}
|
||||
|
||||
export const LoggingExpressMiddleware = HttpLogger({
|
||||
logger,
|
||||
autoLogging: true,
|
||||
genReqId: GenerateRequestId,
|
||||
customLogLevel: (req, res, err) => {
|
||||
const path = getRequestPath(req)
|
||||
const shouldBeDebug = ['/metrics', '/readiness', '/liveness'].includes(path || '')
|
||||
if (shouldBeDebug) return 'debug'
|
||||
if (shouldBeLoggedAsDebug(req)) return 'debug'
|
||||
|
||||
if (res.statusCode >= 400 && res.statusCode < 500) {
|
||||
return 'info'
|
||||
|
||||
Reference in New Issue
Block a user