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",
|
"next-auth": "^4.22.1",
|
||||||
"pg-promise": "^11.4.3",
|
"pg-promise": "^11.4.3",
|
||||||
"pino": "^8.14.1",
|
"pino": "^8.14.1",
|
||||||
|
"pino-pretty": "^10.0.0",
|
||||||
"prom-client": "^14.x.x",
|
"prom-client": "^14.x.x",
|
||||||
"uuid": "^9.0.0"
|
"uuid": "^9.0.0"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import PinoPlugin from "hapi-pino";
|
||||||
import { createServer as createPrometheusServer } from "@promster/server";
|
import { createServer as createPrometheusServer } from "@promster/server";
|
||||||
import { createHttpTerminator } from "http-terminator";
|
import { createHttpTerminator } from "http-terminator";
|
||||||
|
|
||||||
import { getPrettyPrint } from "./logger.js";
|
import { configureLogger } from "./logger.js";
|
||||||
import RequestIdPlugin from "./plugins/request-id.js";
|
import RequestIdPlugin from "./plugins/request-id.js";
|
||||||
import StatusPlugin from "./plugins/status.js";
|
import StatusPlugin from "./plugins/status.js";
|
||||||
import ConfigPlugin from "./plugins/config.js";
|
import ConfigPlugin from "./plugins/config.js";
|
||||||
|
|
@ -79,8 +79,8 @@ export const defaultPlugins = <T extends IMetamigoConfig>(
|
||||||
{
|
{
|
||||||
plugin: PinoPlugin,
|
plugin: PinoPlugin,
|
||||||
options: {
|
options: {
|
||||||
prettyPrint: getPrettyPrint(config),
|
|
||||||
level,
|
level,
|
||||||
|
instance: configureLogger(config),
|
||||||
logRequestStart,
|
logRequestStart,
|
||||||
logRequestComplete,
|
logRequestComplete,
|
||||||
logPayload: logRequestPayload,
|
logPayload: logRequestPayload,
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,15 @@
|
||||||
import pino, { LoggerOptions } from "pino";
|
import pino, { LoggerOptions } from "pino";
|
||||||
import { IMetamigoConfig } from "./config/index.js";
|
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>(
|
export const configureLogger = <T extends IMetamigoConfig>(
|
||||||
config: T
|
config: T
|
||||||
): pino.Logger => {
|
): pino.Logger => {
|
||||||
const { level, redact } = config.logging;
|
const { level, redact } = config.logging;
|
||||||
const options: LoggerOptions = {
|
const options: LoggerOptions = {
|
||||||
level,
|
level,
|
||||||
|
transport: {
|
||||||
|
target: "pino-pretty",
|
||||||
|
},
|
||||||
redact: {
|
redact: {
|
||||||
paths: redact,
|
paths: redact,
|
||||||
remove: true,
|
remove: true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue