diff --git a/packages/cli/src/commands/BaseCommand.ts b/packages/cli/src/commands/BaseCommand.ts index dfaf277ee1858..1ef136b209e3b 100644 --- a/packages/cli/src/commands/BaseCommand.ts +++ b/packages/cli/src/commands/BaseCommand.ts @@ -3,7 +3,6 @@ import type { INodeTypes } from 'n8n-workflow'; import { LoggerProxy, ErrorReporterProxy as ErrorReporter, sleep } from 'n8n-workflow'; import type { IUserSettings } from 'n8n-core'; import { BinaryDataManager, UserSettings } from 'n8n-core'; -import type { Logger } from '@/Logger'; import { getLogger } from '@/Logger'; import config from '@/config'; import * as Db from '@/Db'; @@ -23,7 +22,7 @@ export const UM_FIX_INSTRUCTION = 'Please fix the database by running ./packages/cli/bin/n8n user-management:reset'; export abstract class BaseCommand extends Command { - protected logger: Logger; + protected logger = LoggerProxy.init(getLogger()); protected externalHooks: IExternalHooksClass; @@ -34,9 +33,6 @@ export abstract class BaseCommand extends Command { protected userSettings: IUserSettings; async init(): Promise { - this.logger = getLogger(); - LoggerProxy.init(this.logger); - await initErrorHandling(); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment diff --git a/packages/cli/src/commands/db/revert.ts b/packages/cli/src/commands/db/revert.ts index 8e1ec167c21ca..56de3b566372a 100644 --- a/packages/cli/src/commands/db/revert.ts +++ b/packages/cli/src/commands/db/revert.ts @@ -2,7 +2,6 @@ import { Command, flags } from '@oclif/command'; import type { DataSourceOptions as ConnectionOptions } from 'typeorm'; import { DataSource as Connection } from 'typeorm'; import { LoggerProxy } from 'n8n-workflow'; -import type { Logger } from '@/Logger'; import { getLogger } from '@/Logger'; import { getConnectionOptions } from '@/Db'; import config from '@/config'; @@ -16,14 +15,11 @@ export class DbRevertMigrationCommand extends Command { help: flags.help({ char: 'h' }), }; - private logger: Logger; + protected logger = LoggerProxy.init(getLogger()); private connection: Connection; async init() { - this.logger = getLogger(); - LoggerProxy.init(this.logger); - this.parse(DbRevertMigrationCommand); } diff --git a/packages/workflow/src/LoggerProxy.ts b/packages/workflow/src/LoggerProxy.ts index c056013ddb71e..57cf6419c96b6 100644 --- a/packages/workflow/src/LoggerProxy.ts +++ b/packages/workflow/src/LoggerProxy.ts @@ -3,8 +3,9 @@ import type { ILogger, LogTypes } from './Interfaces'; let logger: ILogger | undefined; -export function init(loggerInstance: ILogger) { +export function init(loggerInstance: L) { logger = loggerInstance; + return loggerInstance; } export function getInstance(): ILogger {