metamigo-common: fix pretty deprecation error in pino logging
This commit is contained in:
parent
9c7a385c77
commit
a33f80c497
3 changed files with 6 additions and 10 deletions
|
|
@ -56,6 +56,7 @@
|
|||
"next-auth": "^4.22.1",
|
||||
"pg-promise": "^11.4.3",
|
||||
"pino": "^8.14.1",
|
||||
"pino-pretty": "^10.0.0",
|
||||
"prom-client": "^14.x.x",
|
||||
"uuid": "^9.0.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import PinoPlugin from "hapi-pino";
|
|||
import { createServer as createPrometheusServer } from "@promster/server";
|
||||
import { createHttpTerminator } from "http-terminator";
|
||||
|
||||
import { getPrettyPrint } from "./logger.js";
|
||||
import { configureLogger } from "./logger.js";
|
||||
import RequestIdPlugin from "./plugins/request-id.js";
|
||||
import StatusPlugin from "./plugins/status.js";
|
||||
import ConfigPlugin from "./plugins/config.js";
|
||||
|
|
@ -79,8 +79,8 @@ export const defaultPlugins = <T extends IMetamigoConfig>(
|
|||
{
|
||||
plugin: PinoPlugin,
|
||||
options: {
|
||||
prettyPrint: getPrettyPrint(config),
|
||||
level,
|
||||
instance: configureLogger(config),
|
||||
logRequestStart,
|
||||
logRequestComplete,
|
||||
logPayload: logRequestPayload,
|
||||
|
|
|
|||
|
|
@ -1,20 +1,15 @@
|
|||
import pino, { LoggerOptions } from "pino";
|
||||
import { IMetamigoConfig } from "./config/index.js";
|
||||
|
||||
export const getPrettyPrint = <T extends IMetamigoConfig>(
|
||||
config: T
|
||||
): boolean => {
|
||||
const { prettyPrint } = config.logging;
|
||||
if (prettyPrint === "auto") return config?.isDev || false;
|
||||
return prettyPrint === true;
|
||||
};
|
||||
|
||||
export const configureLogger = <T extends IMetamigoConfig>(
|
||||
config: T
|
||||
): pino.Logger => {
|
||||
const { level, redact } = config.logging;
|
||||
const options: LoggerOptions = {
|
||||
level,
|
||||
transport: {
|
||||
target: "pino-pretty",
|
||||
},
|
||||
redact: {
|
||||
paths: redact,
|
||||
remove: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue