Updating pino logging to remove health check spam.

This commit is contained in:
mike12345567 2022-08-04 20:23:45 +01:00
parent 1d9d021cc8
commit cfe3db835b
5 changed files with 18 additions and 17 deletions

View File

@ -55,6 +55,7 @@ const env = {
DEFAULT_LICENSE: process.env.DEFAULT_LICENSE, DEFAULT_LICENSE: process.env.DEFAULT_LICENSE,
SERVICE: process.env.SERVICE || "budibase", SERVICE: process.env.SERVICE || "budibase",
MEMORY_LEAK_CHECK: process.env.MEMORY_LEAK_CHECK || false, MEMORY_LEAK_CHECK: process.env.MEMORY_LEAK_CHECK || false,
LOG_LEVEL: process.env.LOG_LEVEL,
DEPLOYMENT_ENVIRONMENT: DEPLOYMENT_ENVIRONMENT:
process.env.DEPLOYMENT_ENVIRONMENT || "docker-compose", process.env.DEPLOYMENT_ENVIRONMENT || "docker-compose",
_set(key: any, value: any) { _set(key: any, value: any) {

View File

@ -15,6 +15,7 @@ import auth from "./auth"
import constants from "./constants" import constants from "./constants"
import * as dbConstants from "./db/constants" import * as dbConstants from "./db/constants"
import logging from "./logging" import logging from "./logging"
import pino from "./pino"
// mimic the outer package exports // mimic the outer package exports
import * as db from "./pkg/db" import * as db from "./pkg/db"
@ -53,6 +54,7 @@ const core = {
errors, errors,
logging, logging,
roles, roles,
...pino,
...errorClasses, ...errorClasses,
} }

View File

@ -0,0 +1,11 @@
const env = require("./environment")
exports.pinoSettings = () => ({
prettyPrint: {
levelFirst: true,
},
level: env.LOG_LEVEL || "error",
autoLogging: {
ignore: req => req.url.includes("/health"),
},
})

View File

@ -15,6 +15,7 @@ const Sentry = require("@sentry/node")
const fileSystem = require("./utilities/fileSystem") const fileSystem = require("./utilities/fileSystem")
const bullboard = require("./automations/bullboard") const bullboard = require("./automations/bullboard")
const { logAlert } = require("@budibase/backend-core/logging") const { logAlert } = require("@budibase/backend-core/logging")
const { pinoSettings } = require("@budibase/backend-core")
const { Thread } = require("./threads") const { Thread } = require("./threads")
import redis from "./utilities/redis" import redis from "./utilities/redis"
import * as migrations from "./migrations" import * as migrations from "./migrations"
@ -35,14 +36,7 @@ app.use(
}) })
) )
app.use( app.use(pino(pinoSettings()))
pino({
prettyPrint: {
levelFirst: true,
},
level: env.LOG_LEVEL || "error",
})
)
if (!env.isTest()) { if (!env.isTest()) {
const plugin = bullboard.init() const plugin = bullboard.init()

View File

@ -18,7 +18,7 @@ const http = require("http")
const api = require("./api") const api = require("./api")
const redis = require("./utilities/redis") const redis = require("./utilities/redis")
const Sentry = require("@sentry/node") const Sentry = require("@sentry/node")
import { events } from "@budibase/backend-core" import { events, pinoSettings } from "@budibase/backend-core"
// this will setup http and https proxies form env variables // this will setup http and https proxies form env variables
bootstrap() bootstrap()
@ -30,14 +30,7 @@ app.keys = ["secret", "key"]
// set up top level koa middleware // set up top level koa middleware
app.use(koaBody({ multipart: true })) app.use(koaBody({ multipart: true }))
app.use(koaSession(app)) app.use(koaSession(app))
app.use( app.use(logger(pinoSettings()))
logger({
prettyPrint: {
levelFirst: true,
},
level: env.LOG_LEVEL || "error",
})
)
// authentication // authentication
app.use(passport.initialize()) app.use(passport.initialize())