Re-writing the disabling of pino/logging - it seems that the pino logger is causing a variety of issues in the built CLI version - easier to offer an environment variable for backend-core which completely removes the logger.
This commit is contained in:
parent
ba47c60803
commit
552499b781
|
@ -154,6 +154,7 @@ const environment = {
|
|||
? process.env.ENABLE_SSO_MAINTENANCE_MODE
|
||||
: false,
|
||||
VERSION: findVersion(),
|
||||
DISABLE_PINO_LOGGER: process.env.DISABLE_PINO_LOGGER,
|
||||
_set(key: any, value: any) {
|
||||
process.env[key] = value
|
||||
// @ts-ignore
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export * as correlation from "./correlation/correlation"
|
||||
export { logger, disableLogger } from "./pino/logger"
|
||||
export { logger } from "./pino/logger"
|
||||
export * from "./alerts"
|
||||
|
||||
// turn off or on context logging i.e. tenantId, appId etc
|
||||
|
|
|
@ -5,19 +5,10 @@ import * as correlation from "../correlation"
|
|||
import { IdentityType } from "@budibase/types"
|
||||
import { LOG_CONTEXT } from "../index"
|
||||
|
||||
// CORE LOGGERS - for disabling
|
||||
|
||||
const BUILT_INS = {
|
||||
log: console.log,
|
||||
error: console.error,
|
||||
info: console.info,
|
||||
warn: console.warn,
|
||||
trace: console.trace,
|
||||
debug: console.debug,
|
||||
}
|
||||
|
||||
// LOGGER
|
||||
|
||||
let pinoInstance: pino.Logger | undefined
|
||||
if (!env.DISABLE_PINO_LOGGER) {
|
||||
const pinoOptions: LoggerOptions = {
|
||||
level: env.LOG_LEVEL,
|
||||
formatters: {
|
||||
|
@ -40,16 +31,7 @@ if (env.isDev()) {
|
|||
}
|
||||
}
|
||||
|
||||
export const logger = pino(pinoOptions)
|
||||
|
||||
export function disableLogger() {
|
||||
console.log = BUILT_INS.log
|
||||
console.error = BUILT_INS.error
|
||||
console.info = BUILT_INS.info
|
||||
console.warn = BUILT_INS.warn
|
||||
console.trace = BUILT_INS.trace
|
||||
console.debug = BUILT_INS.debug
|
||||
}
|
||||
pinoInstance = pino(pinoOptions)
|
||||
|
||||
// CONSOLE OVERRIDES
|
||||
|
||||
|
@ -121,19 +103,19 @@ function getLogParams(args: any[]): [MergingObject, string] {
|
|||
|
||||
console.log = (...arg: any[]) => {
|
||||
const [obj, msg] = getLogParams(arg)
|
||||
logger.info(obj, msg)
|
||||
pinoInstance?.info(obj, msg)
|
||||
}
|
||||
console.info = (...arg: any[]) => {
|
||||
const [obj, msg] = getLogParams(arg)
|
||||
logger.info(obj, msg)
|
||||
pinoInstance?.info(obj, msg)
|
||||
}
|
||||
console.warn = (...arg: any[]) => {
|
||||
const [obj, msg] = getLogParams(arg)
|
||||
logger.warn(obj, msg)
|
||||
pinoInstance?.warn(obj, msg)
|
||||
}
|
||||
console.error = (...arg: any[]) => {
|
||||
const [obj, msg] = getLogParams(arg)
|
||||
logger.error(obj, msg)
|
||||
pinoInstance?.error(obj, msg)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,12 +129,12 @@ console.trace = (...arg: any[]) => {
|
|||
// to get stack trace
|
||||
obj.err = new Error()
|
||||
}
|
||||
logger.trace(obj, msg)
|
||||
pinoInstance?.trace(obj, msg)
|
||||
}
|
||||
|
||||
console.debug = (...arg: any) => {
|
||||
const [obj, msg] = getLogParams(arg)
|
||||
logger.debug(obj, msg)
|
||||
pinoInstance?.debug(obj, msg)
|
||||
}
|
||||
|
||||
// CONTEXT
|
||||
|
@ -186,3 +168,6 @@ const getIdentity = () => {
|
|||
}
|
||||
return identity
|
||||
}
|
||||
}
|
||||
|
||||
export const logger = pinoInstance
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env node
|
||||
process.env.DISABLE_PINO_LOGGER = "1"
|
||||
import "./prebuilds"
|
||||
import "./environment"
|
||||
import { env, logging } from "@budibase/backend-core"
|
||||
logging.disableLogger()
|
||||
import { env } from "@budibase/backend-core"
|
||||
import { getCommands } from "./options"
|
||||
import { Command } from "commander"
|
||||
import { getHelpDescription } from "./utils"
|
||||
|
|
Loading…
Reference in New Issue