mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Missing logs with Pino asynchronous logging (#16299)
* force logger in sync mode when running on the CLI * using the sync logger for all cli commands * using cli logger for app initialization * using pino pretty for log formatting * installed deps Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
This commit is contained in:
@@ -145,6 +145,7 @@
|
||||
"otplib": "12.0.1",
|
||||
"pino": "8.7.0",
|
||||
"pino-http": "8.2.1",
|
||||
"pino-pretty": "9.1.1",
|
||||
"pino-http-print": "3.1.0",
|
||||
"qs": "6.11.0",
|
||||
"rate-limiter-flexible": "2.4.1",
|
||||
|
||||
@@ -14,14 +14,32 @@ const pinoOptions: LoggerOptions = {
|
||||
censor: '--redact--',
|
||||
},
|
||||
};
|
||||
const httpLoggerOptions: LoggerOptions = {
|
||||
level: env.LOG_LEVEL || 'info',
|
||||
redact: {
|
||||
paths: ['req.headers.authorization', `req.cookies.${env.REFRESH_TOKEN_COOKIE_NAME}`],
|
||||
censor: '--redact--',
|
||||
},
|
||||
};
|
||||
|
||||
if (env.LOG_STYLE !== 'raw') {
|
||||
pinoOptions.transport = {
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
ignore: 'hostname,pid',
|
||||
sync: true,
|
||||
},
|
||||
};
|
||||
httpLoggerOptions.transport = {
|
||||
target: 'pino-http-print',
|
||||
options: {
|
||||
all: true,
|
||||
translateTime: 'SYS:HH:MM:ss',
|
||||
relativeUrl: true,
|
||||
prettyOptions: {
|
||||
ignore: 'hostname,pid',
|
||||
sync: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -45,6 +63,14 @@ if (loggerEnvConfig.levels) {
|
||||
};
|
||||
},
|
||||
};
|
||||
httpLoggerOptions.formatters = {
|
||||
level(label: string, number: any) {
|
||||
return {
|
||||
severity: customLogLevels[label] || 'info',
|
||||
level: number,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
delete loggerEnvConfig.levels;
|
||||
}
|
||||
@@ -54,7 +80,7 @@ const logger = pino(merge(pinoOptions, loggerEnvConfig));
|
||||
const httpLoggerEnvConfig = getConfigFromEnv('LOGGER_HTTP', ['LOGGER_HTTP_LOGGER']);
|
||||
|
||||
export const expressLogger = pinoHTTP({
|
||||
logger,
|
||||
logger: pino(merge(httpLoggerOptions, loggerEnvConfig)),
|
||||
...httpLoggerEnvConfig,
|
||||
serializers: {
|
||||
req(request: Request) {
|
||||
|
||||
35
pnpm-lock.yaml
generated
35
pnpm-lock.yaml
generated
@@ -184,6 +184,7 @@ importers:
|
||||
pino: 8.7.0
|
||||
pino-http: 8.2.1
|
||||
pino-http-print: 3.1.0
|
||||
pino-pretty: 9.1.1
|
||||
qs: 6.11.0
|
||||
rate-limiter-flexible: 2.4.1
|
||||
rollup: 3.3.0
|
||||
@@ -279,6 +280,7 @@ importers:
|
||||
pino: 8.7.0
|
||||
pino-http: 8.2.1
|
||||
pino-http-print: 3.1.0
|
||||
pino-pretty: 9.1.1
|
||||
qs: 6.11.0
|
||||
rate-limiter-flexible: 2.4.1
|
||||
rollup: 3.3.0
|
||||
@@ -11187,6 +11189,10 @@ packages:
|
||||
engines: {'0': node >=0.6.0}
|
||||
dev: false
|
||||
|
||||
/fast-copy/3.0.0:
|
||||
resolution: {integrity: sha512-4HzS+9pQ5Yxtv13Lhs1Z1unMXamBdn5nA4bEi1abYpDNSpSp7ODYQ1KPMF6nTatfEzgH6/zPvXKU1zvHiUjWlA==}
|
||||
dev: false
|
||||
|
||||
/fast-deep-equal/3.1.3:
|
||||
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
|
||||
|
||||
@@ -12327,6 +12333,13 @@ packages:
|
||||
engines: {node: '>=14.0.0'}
|
||||
dev: false
|
||||
|
||||
/help-me/4.1.0:
|
||||
resolution: {integrity: sha512-5HMrkOks2j8Fpu2j5nTLhrBhT7VwHwELpqnSnx802ckofys5MO2SkLpgSz3dgNFHV7IYFX2igm5CM75SmuYidw==}
|
||||
dependencies:
|
||||
glob: 8.0.3
|
||||
readable-stream: 3.6.0
|
||||
dev: false
|
||||
|
||||
/hexoid/1.0.0:
|
||||
resolution: {integrity: sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -16458,6 +16471,26 @@ packages:
|
||||
strip-json-comments: 3.1.1
|
||||
dev: false
|
||||
|
||||
/pino-pretty/9.1.1:
|
||||
resolution: {integrity: sha512-iJrnjgR4FWQIXZkUF48oNgoRI9BpyMhaEmihonHeCnZ6F50ZHAS4YGfGBT/ZVNsPmd+hzkIPGzjKdY08+/yAXw==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
colorette: 2.0.19
|
||||
dateformat: 4.6.3
|
||||
fast-copy: 3.0.0
|
||||
fast-safe-stringify: 2.1.1
|
||||
help-me: 4.1.0
|
||||
joycon: 3.1.1
|
||||
minimist: 1.2.6
|
||||
on-exit-leak-free: 2.1.0
|
||||
pino-abstract-transport: 1.0.0
|
||||
pump: 3.0.0
|
||||
readable-stream: 4.2.0
|
||||
secure-json-parse: 2.5.0
|
||||
sonic-boom: 3.2.0
|
||||
strip-json-comments: 3.1.1
|
||||
dev: false
|
||||
|
||||
/pino-std-serializers/6.0.0:
|
||||
resolution: {integrity: sha512-mMMOwSKrmyl+Y12Ri2xhH1lbzQxwwpuru9VjyJpgFIH4asSj88F2csdMwN6+M5g1Ll4rmsYghHLQJw81tgZ7LQ==}
|
||||
|
||||
@@ -19829,7 +19862,7 @@ packages:
|
||||
dependencies:
|
||||
bs-logger: 0.2.6
|
||||
fast-json-stable-stringify: 2.1.0
|
||||
jest: 29.3.1_@types+node@18.11.9
|
||||
jest: 29.3.1_@types+node@18.11.2
|
||||
jest-util: 29.2.1
|
||||
json5: 2.2.1
|
||||
lodash.memoize: 4.1.2
|
||||
|
||||
Reference in New Issue
Block a user