From ed6bd819ab7220d0de8c10ffd08a69b959bbba04 Mon Sep 17 00:00:00 2001 From: xilesun <2013xile@gmail.com> Date: Thu, 13 Jun 2024 20:47:42 +0800 Subject: [PATCH] fix(logger): fix workflow logs --- packages/core/logger/src/config.ts | 5 +---- .../@nocobase/plugin-custom-request/src/server/plugin.ts | 1 - .../plugins/@nocobase/plugin-workflow/src/server/Plugin.ts | 5 ++--- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/core/logger/src/config.ts b/packages/core/logger/src/config.ts index 2960547973..2c87cfcc2a 100644 --- a/packages/core/logger/src/config.ts +++ b/packages/core/logger/src/config.ts @@ -8,10 +8,7 @@ export const getLoggerFilePath = (...paths: string[]): string => { }; export const getLoggerTransport = (): ('console' | 'file' | 'dailyRotateFile')[] => - ( - (process.env.LOGGER_TRANSPORT as any) || - (process.env.APP_ENV === 'development' ? 'console' : 'console,dailyRotateFile') - ).split(','); + ((process.env.LOGGER_TRANSPORT as any) || 'console,dailyRotateFile').split(','); export const getLoggerFormat = (): 'logfmt' | 'json' | 'delimiter' | 'console' => (process.env.LOGGER_FORMAT as any) || (process.env.APP_ENV === 'development' ? 'console' : 'json'); diff --git a/packages/plugins/@nocobase/plugin-custom-request/src/server/plugin.ts b/packages/plugins/@nocobase/plugin-custom-request/src/server/plugin.ts index e73662c7b3..7d9265f39e 100644 --- a/packages/plugins/@nocobase/plugin-custom-request/src/server/plugin.ts +++ b/packages/plugins/@nocobase/plugin-custom-request/src/server/plugin.ts @@ -17,7 +17,6 @@ export class CustomRequestPlugin extends Plugin { const logger = this.createLogger({ dirname: 'custom-request', filename: '%DATE%.log', - transports: [...(process.env.NODE_ENV === 'production' ? ['dailyRotateFile'] : ['console'])], } as LoggerOptions); return logger; diff --git a/packages/plugins/@nocobase/plugin-workflow/src/server/Plugin.ts b/packages/plugins/@nocobase/plugin-workflow/src/server/Plugin.ts index 16540e48f5..716ae31387 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/server/Plugin.ts +++ b/packages/plugins/@nocobase/plugin-workflow/src/server/Plugin.ts @@ -54,9 +54,8 @@ export default class PluginWorkflowServer extends Plugin { } const logger = this.createLogger({ - dirname: path.join('workflows', date), - filename: `${workflowId}.log`, - transports: [...(process.env.NODE_ENV !== 'production' ? ['console'] : ['file'])], + dirname: path.join('workflows', String(workflowId)), + filename: '%DATE%.log', } as LoggerOptions); this.loggerCache.set(key, logger);