fix(logger): fix workflow logs

This commit is contained in:
xilesun 2024-06-13 20:47:42 +08:00
parent a44b9e256c
commit ed6bd819ab
3 changed files with 3 additions and 8 deletions

View File

@ -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');

View File

@ -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;

View File

@ -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);