From 4f5db15c20578c951e580865d81feaa8fc4226c2 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Mon, 27 May 2024 14:05:44 +0200 Subject: [PATCH] logging --- packages/api/src/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/api/src/index.js b/packages/api/src/index.js index 78db2cf4..8910b7e1 100644 --- a/packages/api/src/index.js +++ b/packages/api/src/index.js @@ -30,23 +30,28 @@ function configureLogger() { setLogsFilePath(logsFilePath); setLoggerName('main'); + const consoleLogLevel = process.env.CONSOLE_LOG_LEVEL || process.env.LOG_LEVEL || 'info'; + const fileLogLevel = process.env.FILE_LOG_LEVEL || process.env.LOG_LEVEL || 'debug'; + const logger = createLogger({ base: { pid: process.pid }, targets: [ { type: 'console', // @ts-ignore - level: process.env.CONSOLE_LOG_LEVEL || process.env.LOG_LEVEL || 'info', + level: consoleLogLevel, }, { type: 'stream', // @ts-ignore - level: process.env.FILE_LOG_LEVEL || process.env.LOG_LEVEL || 'debug', + level: fileLogLevel, stream: fs.createWriteStream(logsFilePath, { flags: 'a' }), }, ], }); + logger.info(`Initialized logging, console log level: ${consoleLogLevel}, file log level: ${fileLogLevel}`); + // const streams = []; // if (!platformInfo.isElectron) { // streams.push({