From 5d761a4f64523b70bcf8632c081647637eed7eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20D=C3=A9tr=C3=A9?= Date: Thu, 16 Jan 2025 14:27:08 +0100 Subject: [PATCH 1/2] fix: logger en local via .env --- server/src/server/middlewares/logMiddleware.ts | 5 ++++- server/src/services/logger.ts | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server/src/server/middlewares/logMiddleware.ts b/server/src/server/middlewares/logMiddleware.ts index 45188ab1d..de77c1310 100644 --- a/server/src/server/middlewares/logMiddleware.ts +++ b/server/src/server/middlewares/logMiddleware.ts @@ -48,21 +48,24 @@ const withoutSensibleFields = (obj: unknown, seen: Set): unknown => { export function logMiddleware(): FastifyLoggerOptions | PinoLoggerOptions | false { if (config.log.forceLocalLogs && config.env === "local") { return { + level: config.log.level, transport: { target: "pino-pretty", options: { translateTime: "HH:MM:ss Z", ignore: "pid,hostname", + level: config.log.level, }, }, }; } - if (process.env.NODE_ENV === "test" || config.env === "local") { + if (process.env.NODE_ENV === "test") { return false; } const defaultSettings = { + level: config.log.level, serializers: { req: (request: FastifyRequest) => { return { diff --git a/server/src/services/logger.ts b/server/src/services/logger.ts index dad314ac3..4b90eb7f4 100644 --- a/server/src/services/logger.ts +++ b/server/src/services/logger.ts @@ -67,13 +67,18 @@ function getTransport() { colorize: true, messageKey: "message", messageFormat: "{if module} [{module}] - {end} {message}", + level: config.log.level }, }; } return { target: "pino/file", - options: { destination: 1, ignore: "pid,hostname" }, + options: { + destination: 1, + ignore: "pid,hostname", + level: config.log.level + }, }; } @@ -109,7 +114,7 @@ export function createJobProcessorLogger(logger: PinoLogger): ILogger { const logger = pino({ name: config.productName, enabled: process.env.NODE_ENV !== "test", - level: config.env !== "production" ? "debug" : "info", + level: config.log.level, transport: getTransport(), messageKey: "message", formatters: { From 42f24a92bec6347c7079bfd4276e048b6e1fe329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20D=C3=A9tr=C3=A9?= Date: Thu, 16 Jan 2025 14:27:53 +0100 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20augmentation=20de=20la=20m=C3=A9mo?= =?UTF-8?q?ire=20allou=C3=A9e=20au=20docker=20pgsql=20en=20local?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index c6c4eca6e..e3faebbeb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,7 @@ services: - POSTGRES_PASSWORD=password ports: - "127.0.0.1:5432:5432" + shm_size: 1gb volumes: - pilotage_postgres_data:/var/lib/postgresql/data:z - ./server/seed/seed_schema.dump:/seed_schema.dump