fix LOGGER_LEVELS array being split as string (#12342)

* fix LOGGER_LEVELS array being split as string

* use toArray

* some basic tests
This commit is contained in:
Azri Kahar
2022-03-24 21:08:43 +08:00
committed by GitHub
parent 1c7a07d3b7
commit ce0169d5c8
3 changed files with 69 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import pinoHTTP, { stdSerializers } from 'pino-http';
import { getConfigFromEnv } from './utils/get-config-from-env';
import { URL } from 'url';
import env from './env';
import { toArray } from '@directus/shared/utils';
const pinoOptions: LoggerOptions = {
level: env.LOG_LEVEL || 'info',
@@ -24,7 +25,7 @@ const loggerEnvConfig = getConfigFromEnv('LOGGER_', 'LOGGER_HTTP');
if (loggerEnvConfig.levels) {
const customLogLevels: { [key: string]: string } = {};
for (const el of loggerEnvConfig.levels.split(',')) {
for (const el of toArray(loggerEnvConfig.levels)) {
const key_val = el.split(':');
customLogLevels[key_val[0].trim()] = key_val[1].trim();
}