From 471d7b9420c17cd8aa032232d07f6f8b039ead13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Mon, 23 Dec 2024 13:46:13 +0100 Subject: [PATCH] refactor(core): Move Logger to `core` (no-changelog) (#12310) --- packages/@n8n/task-runner/src/start.ts | 2 +- packages/cli/package.json | 4 +- packages/cli/src/abstract-server.ts | 2 +- packages/cli/src/active-executions.ts | 2 +- packages/cli/src/active-workflow-manager.ts | 2 +- packages/cli/src/auth/auth.service.ts | 2 +- packages/cli/src/commands/base-command.ts | 2 +- .../src/commands/db/__tests__/revert.test.ts | 2 +- packages/cli/src/commands/db/revert.ts | 2 +- packages/cli/src/commands/worker.ts | 3 +- .../concurrency-control.service.ts | 2 +- packages/cli/src/config/index.ts | 25 ++++++---- .../cli/src/controllers/auth.controller.ts | 2 +- .../cli/src/controllers/e2e.controller.ts | 2 +- .../src/controllers/invitation.controller.ts | 2 +- packages/cli/src/controllers/me.controller.ts | 2 +- .../oauth1-credential.controller.test.ts | 2 +- .../oauth2-credential.controller.test.ts | 2 +- .../oauth/abstract-oauth.controller.ts | 3 +- .../cli/src/controllers/owner.controller.ts | 2 +- .../controllers/password-reset.controller.ts | 2 +- .../cli/src/controllers/users.controller.ts | 2 +- .../workflow-statistics.controller.ts | 2 +- packages/cli/src/crash-journal.ts | 3 +- packages/cli/src/credentials-overwrites.ts | 2 +- .../src/credentials/credentials.controller.ts | 2 +- .../src/credentials/credentials.service.ts | 3 +- .../repositories/execution.repository.ts | 3 +- .../databases/subscribers/user-subscriber.ts | 4 +- packages/cli/src/databases/types.ts | 3 +- .../src/databases/utils/migration-helpers.ts | 3 +- .../src/deprecation/deprecation.service.ts | 3 +- .../__tests__/source-control.service.test.ts | 3 +- .../source-control-export.service.ee.ts | 3 +- .../source-control-git.service.ee.ts | 2 +- .../source-control-helper.ee.ts | 2 +- .../source-control-import.service.ee.ts | 3 +- .../source-control-preferences.service.ee.ts | 3 +- .../source-control.service.ee.ts | 2 +- .../message-event-bus-destination-from-db.ts | 2 +- ...message-event-bus-destination-syslog.ee.ts | 3 +- .../message-event-bus-destination.ee.ts | 2 +- .../message-event-bus-log-writer.ts | 3 +- .../message-event-bus/message-event-bus.ts | 2 +- .../__tests__/save-execution-progress.test.ts | 2 +- .../restore-binary-data-id.ts | 3 +- .../save-execution-progress.ts | 3 +- .../shared/shared-hook-functions.ts | 2 +- .../execution-recovery.service.test.ts | 2 +- .../executions/execution-recovery.service.ts | 3 +- .../cli/src/executions/execution.service.ts | 2 +- .../external-secrets-manager.ee.ts | 3 +- .../aws-secrets/aws-secrets-manager.ts | 2 +- .../azure-key-vault/azure-key-vault.ts | 2 +- .../gcp-secrets-manager.ts | 2 +- .../src/external-secrets/providers/vault.ts | 2 +- packages/cli/src/help.ts | 4 +- packages/cli/src/ldap/ldap.service.ee.ts | 3 +- packages/cli/src/license.ts | 3 +- packages/cli/src/license/license.service.ts | 2 +- .../cli/src/load-nodes-and-credentials.ts | 2 +- packages/cli/src/logging/constants.ts | 3 -- packages/cli/src/logging/types.ts | 14 ------ packages/cli/src/manual-execution.service.ts | 3 +- .../src/push/__tests__/websocket.push.test.ts | 2 +- packages/cli/src/push/abstract.push.ts | 3 +- packages/cli/src/response-helper.ts | 3 +- ...nner-process-restart-loop-detector.test.ts | 2 +- .../__tests__/task-runner-process.test.ts | 2 +- packages/cli/src/runners/runner-ws-server.ts | 2 +- .../cli/src/runners/task-broker.service.ts | 2 +- .../cli/src/runners/task-runner-module.ts | 3 +- .../cli/src/runners/task-runner-process.ts | 2 +- .../cli/src/runners/task-runner-server.ts | 2 +- packages/cli/src/scaling/job-processor.ts | 3 +- .../cli/src/scaling/multi-main-setup.ee.ts | 3 +- .../src/scaling/pubsub/publisher.service.ts | 5 +- .../src/scaling/pubsub/subscriber.service.ts | 5 +- packages/cli/src/scaling/scaling.service.ts | 3 +- packages/cli/src/scaling/worker-server.ts | 3 +- .../risk-reporters/instance-risk-reporter.ts | 3 +- .../src/services/active-workflows.service.ts | 2 +- .../services/community-packages.service.ts | 3 +- .../services/credentials-tester.service.ts | 9 +++- packages/cli/src/services/frontend.service.ts | 3 +- packages/cli/src/services/import.service.ts | 2 +- .../src/services/pruning/pruning.service.ts | 3 +- .../cli/src/services/redis-client.service.ts | 2 +- packages/cli/src/services/user.service.ts | 2 +- .../services/workflow-statistics.service.ts | 2 +- packages/cli/src/shutdown/shutdown.service.ts | 2 +- .../sso/saml/__tests__/saml-validator.test.ts | 3 +- .../saml/__tests__/saml.service.ee.test.ts | 2 +- packages/cli/src/sso/saml/saml-validator.ts | 3 +- packages/cli/src/sso/saml/saml.service.ee.ts | 2 +- .../subworkflow-policy-checker.service.ts | 2 +- packages/cli/src/telemetry/index.ts | 3 +- .../src/user-management/email/node-mailer.ts | 4 +- .../email/user-management-mailer.ts | 2 +- packages/cli/src/wait-tracker.ts | 3 +- packages/cli/src/webhooks/live-webhooks.ts | 2 +- packages/cli/src/webhooks/waiting-webhooks.ts | 2 +- packages/cli/src/webhooks/webhook-helpers.ts | 3 +- packages/cli/src/webhooks/webhook.service.ts | 3 +- .../src/workflow-execute-additional-data.ts | 3 +- packages/cli/src/workflow-runner.ts | 3 +- .../workflows/workflow-execution.service.ts | 3 +- .../workflow-history.service.ee.ts | 2 +- .../workflows/workflow-static-data.service.ts | 3 +- .../cli/src/workflows/workflow.service.ee.ts | 2 +- .../cli/src/workflows/workflow.service.ts | 3 +- .../cli/src/workflows/workflows.controller.ts | 2 +- .../active-workflow-manager.test.ts | 2 +- .../test/integration/pruning.service.test.ts | 2 +- .../test/integration/shared/db/workflows.ts | 1 + .../integration/shared/utils/test-server.ts | 2 +- packages/cli/test/shared/mocking.ts | 3 +- packages/core/package.json | 3 ++ packages/core/src/ActiveWorkflows.ts | 9 ++-- packages/core/src/Constants.ts | 4 ++ packages/core/src/DirectoryLoader.ts | 20 ++++---- packages/core/src/InstanceSettings.ts | 36 +++++++------- packages/core/src/InstanceSettingsConfig.ts | 16 +++++++ packages/core/src/NodeExecuteFunctions.ts | 20 ++++---- .../src/ObjectStore/ObjectStore.service.ee.ts | 6 ++- packages/core/src/SerializedBuffer.ts | 2 +- .../src/__tests__/ActiveWorkflows.test.ts | 7 ++- packages/core/src/error-reporter.ts | 7 +-- packages/core/src/index.ts | 1 + .../src/logging/__tests__/logger.test.ts} | 23 ++++----- .../src/logging/logger.ts} | 30 ++++++++---- .../node-execution-context.ts | 5 +- packages/core/test/InstanceSettings.test.ts | 17 +++++-- .../core/test/ObjectStore.service.test.ts | 3 +- packages/core/test/error-reporter.test.ts | 3 +- packages/core/tsconfig.json | 1 + packages/nodes-base/nodes/Ldap/Helpers.ts | 6 +-- packages/nodes-base/nodes/Ldap/Ldap.node.ts | 9 ++-- packages/workflow/package.json | 3 +- packages/workflow/src/Interfaces.ts | 15 +++++- pnpm-lock.yaml | 48 ++++++++++++------- pnpm-workspace.yaml | 2 + 142 files changed, 328 insertions(+), 302 deletions(-) delete mode 100644 packages/cli/src/logging/constants.ts delete mode 100644 packages/cli/src/logging/types.ts rename packages/{cli/src/logging/__tests__/logger.service.test.ts => core/src/logging/__tests__/logger.test.ts} (93%) rename packages/{cli/src/logging/logger.service.ts => core/src/logging/logger.ts} (89%) diff --git a/packages/@n8n/task-runner/src/start.ts b/packages/@n8n/task-runner/src/start.ts index 391b6ba156c66..93ff7422501b3 100644 --- a/packages/@n8n/task-runner/src/start.ts +++ b/packages/@n8n/task-runner/src/start.ts @@ -56,7 +56,7 @@ void (async function start() { if (config.sentryConfig.sentryDsn) { const { ErrorReporter } = await import('n8n-core'); - errorReporter = new ErrorReporter(); + errorReporter = Container.get(ErrorReporter); await errorReporter.init('task_runner', config.sentryConfig.sentryDsn); } diff --git a/packages/cli/package.json b/packages/cli/package.json index 8e9ff0f7ca483..e005ce30255f8 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -104,7 +104,6 @@ "bcryptjs": "2.4.3", "bull": "4.12.1", "cache-manager": "5.2.3", - "callsites": "3.1.0", "change-case": "4.1.2", "class-transformer": "0.5.1", "class-validator": "0.14.0", @@ -149,7 +148,7 @@ "p-cancelable": "2.1.1", "p-lazy": "3.1.0", "pg": "8.12.0", - "picocolors": "1.0.1", + "picocolors": "catalog:", "pkce-challenge": "3.0.0", "posthog-node": "3.2.1", "prom-client": "13.2.0", @@ -169,7 +168,6 @@ "typedi": "catalog:", "uuid": "catalog:", "validator": "13.7.0", - "winston": "3.14.2", "ws": "8.17.1", "xml2js": "catalog:", "xmllint-wasm": "3.0.1", diff --git a/packages/cli/src/abstract-server.ts b/packages/cli/src/abstract-server.ts index f4a8a5b2ccd8d..aadd41fb051f5 100644 --- a/packages/cli/src/abstract-server.ts +++ b/packages/cli/src/abstract-server.ts @@ -5,6 +5,7 @@ import { engine as expressHandlebars } from 'express-handlebars'; import { readFile } from 'fs/promises'; import type { Server } from 'http'; import isbot from 'isbot'; +import { Logger } from 'n8n-core'; import { Container, Service } from 'typedi'; import config from '@/config'; @@ -12,7 +13,6 @@ import { N8N_VERSION, TEMPLATES_DIR, inDevelopment, inTest } from '@/constants'; import * as Db from '@/db'; import { OnShutdown } from '@/decorators/on-shutdown'; import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logging/logger.service'; import { rawBodyReader, bodyParser, corsMiddleware } from '@/middlewares'; import { send, sendErrorResponse } from '@/response-helper'; import { LiveWebhooks } from '@/webhooks/live-webhooks'; diff --git a/packages/cli/src/active-executions.ts b/packages/cli/src/active-executions.ts index bc18eade16f9c..a3fdcf6fee644 100644 --- a/packages/cli/src/active-executions.ts +++ b/packages/cli/src/active-executions.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import type { IDeferredPromise, IExecuteResponsePromiseData, @@ -18,7 +19,6 @@ import type { IExecutionDb, IExecutionsCurrentSummary, } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { isWorkflowIdValid } from '@/utils'; import { ConcurrencyControlService } from './concurrency/concurrency-control.service'; diff --git a/packages/cli/src/active-workflow-manager.ts b/packages/cli/src/active-workflow-manager.ts index 6ef3753af74be..368e2987c80aa 100644 --- a/packages/cli/src/active-workflow-manager.ts +++ b/packages/cli/src/active-workflow-manager.ts @@ -3,6 +3,7 @@ import { ActiveWorkflows, ErrorReporter, InstanceSettings, + Logger, PollContext, TriggerContext, } from 'n8n-core'; @@ -42,7 +43,6 @@ import { OnShutdown } from '@/decorators/on-shutdown'; import { ExecutionService } from '@/executions/execution.service'; import { ExternalHooks } from '@/external-hooks'; import type { IWorkflowDb } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { Publisher } from '@/scaling/pubsub/publisher.service'; import { ActiveWorkflowsService } from '@/services/active-workflows.service'; diff --git a/packages/cli/src/auth/auth.service.ts b/packages/cli/src/auth/auth.service.ts index 492e22ab53331..3a2e4fb0cb127 100644 --- a/packages/cli/src/auth/auth.service.ts +++ b/packages/cli/src/auth/auth.service.ts @@ -2,6 +2,7 @@ import { GlobalConfig } from '@n8n/config'; import { createHash } from 'crypto'; import type { NextFunction, Response } from 'express'; import { JsonWebTokenError, TokenExpiredError } from 'jsonwebtoken'; +import { Logger } from 'n8n-core'; import Container, { Service } from 'typedi'; import config from '@/config'; @@ -12,7 +13,6 @@ import { UserRepository } from '@/databases/repositories/user.repository'; import { AuthError } from '@/errors/response-errors/auth.error'; import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import type { AuthenticatedRequest } from '@/requests'; import { JwtService } from '@/services/jwt.service'; import { UrlService } from '@/services/url.service'; diff --git a/packages/cli/src/commands/base-command.ts b/packages/cli/src/commands/base-command.ts index 286fec1de6bec..a10c386f4222f 100644 --- a/packages/cli/src/commands/base-command.ts +++ b/packages/cli/src/commands/base-command.ts @@ -4,6 +4,7 @@ import { Command, Errors } from '@oclif/core'; import { BinaryDataService, InstanceSettings, + Logger, ObjectStoreService, DataDeduplicationService, ErrorReporter, @@ -25,7 +26,6 @@ import { ExternalHooks } from '@/external-hooks'; import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; import { License } from '@/license'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { PostHogClient } from '@/posthog'; import { ShutdownService } from '@/shutdown/shutdown.service'; diff --git a/packages/cli/src/commands/db/__tests__/revert.test.ts b/packages/cli/src/commands/db/__tests__/revert.test.ts index ce3911b2b617e..8fdabafbec462 100644 --- a/packages/cli/src/commands/db/__tests__/revert.test.ts +++ b/packages/cli/src/commands/db/__tests__/revert.test.ts @@ -1,10 +1,10 @@ import type { Migration, MigrationExecutor } from '@n8n/typeorm'; import { type DataSource } from '@n8n/typeorm'; import { mock } from 'jest-mock-extended'; +import { Logger } from 'n8n-core'; import { main } from '@/commands/db/revert'; import type { IrreversibleMigration, ReversibleMigration } from '@/databases/types'; -import { Logger } from '@/logging/logger.service'; import { mockInstance } from '@test/mocking'; const logger = mockInstance(Logger); diff --git a/packages/cli/src/commands/db/revert.ts b/packages/cli/src/commands/db/revert.ts index 45100444059d0..bc9e0f6b3f467 100644 --- a/packages/cli/src/commands/db/revert.ts +++ b/packages/cli/src/commands/db/revert.ts @@ -3,12 +3,12 @@ import type { DataSourceOptions as ConnectionOptions } from '@n8n/typeorm'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { MigrationExecutor, DataSource as Connection } from '@n8n/typeorm'; import { Command, Flags } from '@oclif/core'; +import { Logger } from 'n8n-core'; import { Container } from 'typedi'; import { getConnectionOptions } from '@/databases/config'; import type { Migration } from '@/databases/types'; import { wrapMigration } from '@/databases/utils/migration-helpers'; -import { Logger } from '@/logging/logger.service'; // This function is extracted to make it easier to unit test it. // Mocking turned into a mess due to this command using typeorm and the db diff --git a/packages/cli/src/commands/worker.ts b/packages/cli/src/commands/worker.ts index 64c5a34dae680..ac413077d2f36 100644 --- a/packages/cli/src/commands/worker.ts +++ b/packages/cli/src/commands/worker.ts @@ -7,7 +7,6 @@ import { WorkerMissingEncryptionKey } from '@/errors/worker-missing-encryption-k import { EventMessageGeneric } from '@/eventbus/event-message-classes/event-message-generic'; import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { LogStreamingEventRelay } from '@/events/relays/log-streaming.event-relay'; -import { Logger } from '@/logging/logger.service'; import { PubSubHandler } from '@/scaling/pubsub/pubsub-handler'; import { Subscriber } from '@/scaling/pubsub/subscriber.service'; import type { ScalingService } from '@/scaling/scaling.service'; @@ -67,7 +66,7 @@ export class Worker extends BaseCommand { super(argv, cmdConfig); - this.logger = Container.get(Logger).scoped('scaling'); + this.logger = this.logger.scoped('scaling'); } async init() { diff --git a/packages/cli/src/concurrency/concurrency-control.service.ts b/packages/cli/src/concurrency/concurrency-control.service.ts index 3896daad2e28f..ede6cf899748b 100644 --- a/packages/cli/src/concurrency/concurrency-control.service.ts +++ b/packages/cli/src/concurrency/concurrency-control.service.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import type { WorkflowExecuteMode as ExecutionMode } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -7,7 +8,6 @@ import { InvalidConcurrencyLimitError } from '@/errors/invalid-concurrency-limit import { UnknownExecutionModeError } from '@/errors/unknown-execution-mode.error'; import { EventService } from '@/events/event.service'; import type { IExecutingWorkflowData } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { Telemetry } from '@/telemetry'; import { ConcurrencyQueue } from './concurrency-queue'; diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts index 63497600fe300..1ba49a1ef4ce1 100644 --- a/packages/cli/src/config/index.ts +++ b/packages/cli/src/config/index.ts @@ -3,7 +3,9 @@ import convict from 'convict'; import { flatten } from 'flat'; import { readFileSync } from 'fs'; import merge from 'lodash/merge'; +import { Logger } from 'n8n-core'; import { ApplicationError, setGlobalState } from 'n8n-workflow'; +import assert from 'node:assert'; import colors from 'picocolors'; import { Container } from 'typedi'; @@ -31,13 +33,15 @@ const config = convict(schema, { args: [] }); // eslint-disable-next-line @typescript-eslint/unbound-method config.getEnv = config.get; +const logger = Container.get(Logger); +const globalConfig = Container.get(GlobalConfig); + // Load overwrites when not in tests if (!inE2ETests && !inTest) { // Overwrite default configuration with settings which got defined in // optional configuration files const { N8N_CONFIG_FILES } = process.env; if (N8N_CONFIG_FILES !== undefined) { - const globalConfig = Container.get(GlobalConfig); const configFiles = N8N_CONFIG_FILES.split(','); for (const configFile of configFiles) { if (!configFile) continue; @@ -58,9 +62,10 @@ if (!inE2ETests && !inTest) { } } } - console.debug('Loaded config overwrites from', configFile); + logger.debug(`Loaded config overwrites from ${configFile}`); } catch (error) { - console.error('Error loading config file', configFile, error); + assert(error instanceof Error); + logger.error(`Error loading config file ${configFile}`, { error }); } } } @@ -96,7 +101,7 @@ config.validate({ const userManagement = config.get('userManagement'); if (userManagement.jwtRefreshTimeoutHours >= userManagement.jwtSessionDurationHours) { if (!inTest) - console.warn( + logger.warn( 'N8N_USER_MANAGEMENT_JWT_REFRESH_TIMEOUT_HOURS needs to smaller than N8N_USER_MANAGEMENT_JWT_DURATION_HOURS. Setting N8N_USER_MANAGEMENT_JWT_REFRESH_TIMEOUT_HOURS to 0 for now.', ); @@ -105,16 +110,16 @@ if (userManagement.jwtRefreshTimeoutHours >= userManagement.jwtSessionDurationHo const executionProcess = config.getEnv('executions.process'); if (executionProcess) { - console.error( - colors.yellow('Please unset the deprecated env variable'), - colors.bold(colors.yellow('EXECUTIONS_PROCESS')), + logger.error( + colors.yellow('Please unset the deprecated env variable') + + colors.bold(colors.yellow('EXECUTIONS_PROCESS')), ); } if (executionProcess === 'own') { - console.error( + logger.error( colors.bold(colors.red('Application failed to start because "Own" mode has been removed.')), ); - console.error( + logger.error( colors.red( 'If you need the isolation and performance gains, please consider using queue mode instead.\n\n', ), @@ -123,7 +128,7 @@ if (executionProcess === 'own') { } setGlobalState({ - defaultTimezone: Container.get(GlobalConfig).generic.timezone, + defaultTimezone: globalConfig.generic.timezone, }); // eslint-disable-next-line import/no-default-export diff --git a/packages/cli/src/controllers/auth.controller.ts b/packages/cli/src/controllers/auth.controller.ts index 46ee73a562c1a..faf24ed669bdd 100644 --- a/packages/cli/src/controllers/auth.controller.ts +++ b/packages/cli/src/controllers/auth.controller.ts @@ -1,4 +1,5 @@ import { Response } from 'express'; +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import validator from 'validator'; @@ -14,7 +15,6 @@ import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; import { EventService } from '@/events/event.service'; import type { PublicUser } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { MfaService } from '@/mfa/mfa.service'; import { PostHogClient } from '@/posthog'; import { AuthenticatedRequest, LoginRequest, UserRequest } from '@/requests'; diff --git a/packages/cli/src/controllers/e2e.controller.ts b/packages/cli/src/controllers/e2e.controller.ts index a61342320dd04..9d0404d3126d2 100644 --- a/packages/cli/src/controllers/e2e.controller.ts +++ b/packages/cli/src/controllers/e2e.controller.ts @@ -1,5 +1,6 @@ import type { PushMessage } from '@n8n/api-types'; import { Request } from 'express'; +import { Logger } from 'n8n-core'; import Container from 'typedi'; import { v4 as uuid } from 'uuid'; @@ -14,7 +15,6 @@ import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus' import type { BooleanLicenseFeature, NumericLicenseFeature } from '@/interfaces'; import type { FeatureReturnType } from '@/license'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { MfaService } from '@/mfa/mfa.service'; import { Push } from '@/push'; import type { UserSetupPayload } from '@/requests'; diff --git a/packages/cli/src/controllers/invitation.controller.ts b/packages/cli/src/controllers/invitation.controller.ts index cbd2afb9f432c..24cff10c643f5 100644 --- a/packages/cli/src/controllers/invitation.controller.ts +++ b/packages/cli/src/controllers/invitation.controller.ts @@ -1,4 +1,5 @@ import { Response } from 'express'; +import { Logger } from 'n8n-core'; import validator from 'validator'; import { AuthService } from '@/auth/auth.service'; @@ -12,7 +13,6 @@ import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { PostHogClient } from '@/posthog'; import { UserRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; diff --git a/packages/cli/src/controllers/me.controller.ts b/packages/cli/src/controllers/me.controller.ts index a7fb7235fddd5..f56d62aebd559 100644 --- a/packages/cli/src/controllers/me.controller.ts +++ b/packages/cli/src/controllers/me.controller.ts @@ -5,6 +5,7 @@ import { } from '@n8n/api-types'; import { plainToInstance } from 'class-transformer'; import { Response } from 'express'; +import { Logger } from 'n8n-core'; import { AuthService } from '@/auth/auth.service'; import type { User } from '@/databases/entities/user'; @@ -16,7 +17,6 @@ import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; import type { PublicUser } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { MfaService } from '@/mfa/mfa.service'; import { AuthenticatedRequest, MeRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; diff --git a/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts b/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts index 2d76642266c51..c7990ddbfdc6a 100644 --- a/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts +++ b/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts @@ -2,6 +2,7 @@ import Csrf from 'csrf'; import type { Response } from 'express'; import { mock } from 'jest-mock-extended'; import { Cipher } from 'n8n-core'; +import { Logger } from 'n8n-core'; import nock from 'nock'; import Container from 'typedi'; @@ -16,7 +17,6 @@ import { VariablesService } from '@/environments/variables/variables.service.ee' import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logging/logger.service'; import type { OAuthRequest } from '@/requests'; import { SecretsHelper } from '@/secrets-helpers'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts b/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts index b2bd987fb0836..ca9e4db5c6b42 100644 --- a/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts +++ b/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts @@ -2,6 +2,7 @@ import Csrf from 'csrf'; import { type Response } from 'express'; import { mock } from 'jest-mock-extended'; import { Cipher } from 'n8n-core'; +import { Logger } from 'n8n-core'; import nock from 'nock'; import Container from 'typedi'; @@ -16,7 +17,6 @@ import { VariablesService } from '@/environments/variables/variables.service.ee' import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logging/logger.service'; import type { OAuthRequest } from '@/requests'; import { SecretsHelper } from '@/secrets-helpers'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts b/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts index 3f5c20dfc3c8c..97fb7be24af28 100644 --- a/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts +++ b/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts @@ -1,7 +1,7 @@ import { GlobalConfig } from '@n8n/config'; import Csrf from 'csrf'; import type { Response } from 'express'; -import { Credentials } from 'n8n-core'; +import { Credentials, Logger } from 'n8n-core'; import type { ICredentialDataDecryptedObject, IWorkflowExecuteAdditionalData } from 'n8n-workflow'; import { jsonParse, ApplicationError } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -16,7 +16,6 @@ import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; import type { ICredentialsDb } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import type { AuthenticatedRequest, OAuthRequest } from '@/requests'; import { UrlService } from '@/services/url.service'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; diff --git a/packages/cli/src/controllers/owner.controller.ts b/packages/cli/src/controllers/owner.controller.ts index 47d50ad3f042d..1db250c488a40 100644 --- a/packages/cli/src/controllers/owner.controller.ts +++ b/packages/cli/src/controllers/owner.controller.ts @@ -1,4 +1,5 @@ import { Response } from 'express'; +import { Logger } from 'n8n-core'; import validator from 'validator'; import { AuthService } from '@/auth/auth.service'; @@ -9,7 +10,6 @@ import { GlobalScope, Post, RestController } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { EventService } from '@/events/event.service'; import { validateEntity } from '@/generic-helpers'; -import { Logger } from '@/logging/logger.service'; import { PostHogClient } from '@/posthog'; import { OwnerRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; diff --git a/packages/cli/src/controllers/password-reset.controller.ts b/packages/cli/src/controllers/password-reset.controller.ts index 2179ff3d9e737..cb5e2c6f8b72f 100644 --- a/packages/cli/src/controllers/password-reset.controller.ts +++ b/packages/cli/src/controllers/password-reset.controller.ts @@ -1,4 +1,5 @@ import { Response } from 'express'; +import { Logger } from 'n8n-core'; import validator from 'validator'; import { AuthService } from '@/auth/auth.service'; @@ -13,7 +14,6 @@ import { UnprocessableRequestError } from '@/errors/response-errors/unprocessabl import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { MfaService } from '@/mfa/mfa.service'; import { PasswordResetRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; diff --git a/packages/cli/src/controllers/users.controller.ts b/packages/cli/src/controllers/users.controller.ts index 8e19be894d438..4cfa18a1e3396 100644 --- a/packages/cli/src/controllers/users.controller.ts +++ b/packages/cli/src/controllers/users.controller.ts @@ -1,5 +1,6 @@ import { RoleChangeRequestDto, SettingsUpdateRequestDto } from '@n8n/api-types'; import { Response } from 'express'; +import { Logger } from 'n8n-core'; import { AuthService } from '@/auth/auth.service'; import { CredentialsService } from '@/credentials/credentials.service'; @@ -18,7 +19,6 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import type { PublicUser } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { listQueryMiddleware } from '@/middlewares'; import { AuthenticatedRequest, ListQuery, UserRequest } from '@/requests'; import { ProjectService } from '@/services/project.service'; diff --git a/packages/cli/src/controllers/workflow-statistics.controller.ts b/packages/cli/src/controllers/workflow-statistics.controller.ts index 58c99727db1df..b14afc9179c1e 100644 --- a/packages/cli/src/controllers/workflow-statistics.controller.ts +++ b/packages/cli/src/controllers/workflow-statistics.controller.ts @@ -1,4 +1,5 @@ import { Response, NextFunction } from 'express'; +import { Logger } from 'n8n-core'; import type { WorkflowStatistics } from '@/databases/entities/workflow-statistics'; import { StatisticsNames } from '@/databases/entities/workflow-statistics'; @@ -7,7 +8,6 @@ import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow- import { Get, Middleware, RestController } from '@/decorators'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import type { IWorkflowStatisticsDataLoaded } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { StatisticsRequest } from './workflow-statistics.types'; diff --git a/packages/cli/src/crash-journal.ts b/packages/cli/src/crash-journal.ts index 577a2f34fe9d0..8afae1e88c96a 100644 --- a/packages/cli/src/crash-journal.ts +++ b/packages/cli/src/crash-journal.ts @@ -1,12 +1,11 @@ import { existsSync } from 'fs'; import { mkdir, utimes, open, rm } from 'fs/promises'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { sleep } from 'n8n-workflow'; import { join, dirname } from 'path'; import { Container } from 'typedi'; import { inProduction } from '@/constants'; -import { Logger } from '@/logging/logger.service'; export const touchFile = async (filePath: string): Promise => { await mkdir(dirname(filePath), { recursive: true }); diff --git a/packages/cli/src/credentials-overwrites.ts b/packages/cli/src/credentials-overwrites.ts index ed1b492dc68ea..30f6bedfb8ba0 100644 --- a/packages/cli/src/credentials-overwrites.ts +++ b/packages/cli/src/credentials-overwrites.ts @@ -1,11 +1,11 @@ import { GlobalConfig } from '@n8n/config'; +import { Logger } from 'n8n-core'; import type { ICredentialDataDecryptedObject } from 'n8n-workflow'; import { deepCopy, jsonParse } from 'n8n-workflow'; import { Service } from 'typedi'; import { CredentialTypes } from '@/credential-types'; import type { ICredentialsOverwrite } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; @Service() export class CredentialsOverwrites { diff --git a/packages/cli/src/credentials/credentials.controller.ts b/packages/cli/src/credentials/credentials.controller.ts index 76db501cf7959..3868c3b87f3a3 100644 --- a/packages/cli/src/credentials/credentials.controller.ts +++ b/packages/cli/src/credentials/credentials.controller.ts @@ -1,6 +1,7 @@ import { GlobalConfig } from '@n8n/config'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In } from '@n8n/typeorm'; +import { Logger } from 'n8n-core'; import { deepCopy } from 'n8n-workflow'; import { z } from 'zod'; @@ -23,7 +24,6 @@ import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { EventService } from '@/events/event.service'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { listQueryMiddleware } from '@/middlewares'; import { CredentialRequest } from '@/requests'; import { NamingService } from '@/services/naming.service'; diff --git a/packages/cli/src/credentials/credentials.service.ts b/packages/cli/src/credentials/credentials.service.ts index f9bbf89e57cdb..8261b1364974f 100644 --- a/packages/cli/src/credentials/credentials.service.ts +++ b/packages/cli/src/credentials/credentials.service.ts @@ -6,7 +6,7 @@ import { type FindOptionsRelations, type FindOptionsWhere, } from '@n8n/typeorm'; -import { Credentials } from 'n8n-core'; +import { Credentials, Logger } from 'n8n-core'; import type { ICredentialDataDecryptedObject, ICredentialsDecrypted, @@ -33,7 +33,6 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; import type { ICredentialsDb } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { userHasScopes } from '@/permissions/check-access'; import type { CredentialRequest, ListQuery } from '@/requests'; import { CredentialsTester } from '@/services/credentials-tester.service'; diff --git a/packages/cli/src/databases/repositories/execution.repository.ts b/packages/cli/src/databases/repositories/execution.repository.ts index fbcb7de445463..617dde913681a 100644 --- a/packages/cli/src/databases/repositories/execution.repository.ts +++ b/packages/cli/src/databases/repositories/execution.repository.ts @@ -21,7 +21,7 @@ import { import { DateUtils } from '@n8n/typeorm/util/DateUtils'; import { parse, stringify } from 'flatted'; import pick from 'lodash/pick'; -import { BinaryDataService, ErrorReporter } from 'n8n-core'; +import { BinaryDataService, ErrorReporter, Logger } from 'n8n-core'; import { ExecutionCancelledError, ApplicationError } from 'n8n-workflow'; import type { AnnotationVote, @@ -42,7 +42,6 @@ import type { IExecutionFlattedDb, IExecutionResponse, } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { separate } from '@/utils'; import { ExecutionDataRepository } from './execution-data.repository'; diff --git a/packages/cli/src/databases/subscribers/user-subscriber.ts b/packages/cli/src/databases/subscribers/user-subscriber.ts index 1c55572b14e01..2dc6a1d8e24dd 100644 --- a/packages/cli/src/databases/subscribers/user-subscriber.ts +++ b/packages/cli/src/databases/subscribers/user-subscriber.ts @@ -1,11 +1,9 @@ import type { EntitySubscriberInterface, UpdateEvent } from '@n8n/typeorm'; import { EventSubscriber } from '@n8n/typeorm'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import { Container } from 'typedi'; -import { Logger } from '@/logging/logger.service'; - import { Project } from '../entities/project'; import { User } from '../entities/user'; import { UserRepository } from '../repositories/user.repository'; diff --git a/packages/cli/src/databases/types.ts b/packages/cli/src/databases/types.ts index 2bb1802bf248b..dce7d9d24361e 100644 --- a/packages/cli/src/databases/types.ts +++ b/packages/cli/src/databases/types.ts @@ -1,8 +1,7 @@ import type { QueryRunner, ObjectLiteral } from '@n8n/typeorm'; +import type { Logger } from 'n8n-core'; import type { INodeTypes } from 'n8n-workflow'; -import type { Logger } from '@/logging/logger.service'; - import type { createSchemaBuilder } from './dsl'; export type DatabaseType = 'mariadb' | 'postgresdb' | 'mysqldb' | 'sqlite'; diff --git a/packages/cli/src/databases/utils/migration-helpers.ts b/packages/cli/src/databases/utils/migration-helpers.ts index 1093096f430be..70839b9337873 100644 --- a/packages/cli/src/databases/utils/migration-helpers.ts +++ b/packages/cli/src/databases/utils/migration-helpers.ts @@ -2,14 +2,13 @@ import { GlobalConfig } from '@n8n/config'; import type { ObjectLiteral } from '@n8n/typeorm'; import type { QueryRunner } from '@n8n/typeorm/query-runner/QueryRunner'; import { readFileSync, rmSync } from 'fs'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, jsonParse } from 'n8n-workflow'; import { Container } from 'typedi'; import { inTest } from '@/constants'; import { createSchemaBuilder } from '@/databases/dsl'; import type { BaseMigration, Migration, MigrationContext, MigrationFn } from '@/databases/types'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; const PERSONALIZATION_SURVEY_FILENAME = 'personalizationSurvey.json'; diff --git a/packages/cli/src/deprecation/deprecation.service.ts b/packages/cli/src/deprecation/deprecation.service.ts index fef25ff0dd9cb..b3c4cb7d21173 100644 --- a/packages/cli/src/deprecation/deprecation.service.ts +++ b/packages/cli/src/deprecation/deprecation.service.ts @@ -1,8 +1,7 @@ +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import { Service } from 'typedi'; -import { Logger } from '@/logging/logger.service'; - type EnvVarName = string; type Deprecation = { diff --git a/packages/cli/src/environments/source-control/__tests__/source-control.service.test.ts b/packages/cli/src/environments/source-control/__tests__/source-control.service.test.ts index e1ebf0e56aade..1599f7b4bde3a 100644 --- a/packages/cli/src/environments/source-control/__tests__/source-control.service.test.ts +++ b/packages/cli/src/environments/source-control/__tests__/source-control.service.test.ts @@ -1,12 +1,13 @@ import { mock } from 'jest-mock-extended'; import { InstanceSettings } from 'n8n-core'; +import { Container } from 'typedi'; import { SourceControlPreferencesService } from '@/environments/source-control/source-control-preferences.service.ee'; import { SourceControlService } from '@/environments/source-control/source-control.service.ee'; describe('SourceControlService', () => { const preferencesService = new SourceControlPreferencesService( - new InstanceSettings(mock()), + Container.get(InstanceSettings), mock(), mock(), ); diff --git a/packages/cli/src/environments/source-control/source-control-export.service.ee.ts b/packages/cli/src/environments/source-control/source-control-export.service.ee.ts index 03352410f435f..cb678d534d41c 100644 --- a/packages/cli/src/environments/source-control/source-control-export.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-export.service.ee.ts @@ -1,5 +1,5 @@ import { rmSync } from 'fs'; -import { Credentials, InstanceSettings } from 'n8n-core'; +import { Credentials, InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, type ICredentialDataDecryptedObject } from 'n8n-workflow'; import { writeFile as fsWriteFile, rm as fsRm } from 'node:fs/promises'; import path from 'path'; @@ -11,7 +11,6 @@ import { SharedWorkflowRepository } from '@/databases/repositories/shared-workfl import { TagRepository } from '@/databases/repositories/tag.repository'; import { WorkflowTagMappingRepository } from '@/databases/repositories/workflow-tag-mapping.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { Logger } from '@/logging/logger.service'; import { SOURCE_CONTROL_CREDENTIAL_EXPORT_FOLDER, diff --git a/packages/cli/src/environments/source-control/source-control-git.service.ee.ts b/packages/cli/src/environments/source-control/source-control-git.service.ee.ts index 99571cdd528d0..0d87d4c2d18c5 100644 --- a/packages/cli/src/environments/source-control/source-control-git.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-git.service.ee.ts @@ -1,4 +1,5 @@ import { execSync } from 'child_process'; +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import path from 'path'; import type { @@ -14,7 +15,6 @@ import type { import { Service } from 'typedi'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logging/logger.service'; import { OwnershipService } from '@/services/ownership.service'; import { diff --git a/packages/cli/src/environments/source-control/source-control-helper.ee.ts b/packages/cli/src/environments/source-control/source-control-helper.ee.ts index 00a9875741eda..6e8b92f09b444 100644 --- a/packages/cli/src/environments/source-control/source-control-helper.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-helper.ee.ts @@ -1,12 +1,12 @@ import { generateKeyPairSync } from 'crypto'; import { constants as fsConstants, mkdirSync, accessSync } from 'fs'; +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import { ok } from 'node:assert/strict'; import path from 'path'; import { Container } from 'typedi'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { isContainedWithin } from '@/utils/path-util'; import { diff --git a/packages/cli/src/environments/source-control/source-control-import.service.ee.ts b/packages/cli/src/environments/source-control/source-control-import.service.ee.ts index 2e7da80c13312..10ae293b601da 100644 --- a/packages/cli/src/environments/source-control/source-control-import.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-import.service.ee.ts @@ -1,7 +1,7 @@ // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In } from '@n8n/typeorm'; import glob from 'fast-glob'; -import { Credentials, ErrorReporter, InstanceSettings } from 'n8n-core'; +import { Credentials, ErrorReporter, InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, jsonParse, ensureError } from 'n8n-workflow'; import { readFile as fsReadFile } from 'node:fs/promises'; import path from 'path'; @@ -23,7 +23,6 @@ import { VariablesRepository } from '@/databases/repositories/variables.reposito import { WorkflowTagMappingRepository } from '@/databases/repositories/workflow-tag-mapping.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import type { IWorkflowToImport } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { isUniqueConstraintError } from '@/response-helper'; import { assertNever } from '@/utils'; diff --git a/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts b/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts index 7c061b6c3c5be..ec46e024549aa 100644 --- a/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts @@ -1,7 +1,7 @@ import type { ValidationError } from 'class-validator'; import { validate } from 'class-validator'; import { rm as fsRm } from 'fs/promises'; -import { Cipher, InstanceSettings } from 'n8n-core'; +import { Cipher, InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, jsonParse } from 'n8n-workflow'; import { writeFile, chmod, readFile } from 'node:fs/promises'; import path from 'path'; @@ -9,7 +9,6 @@ import Container, { Service } from 'typedi'; import config from '@/config'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { Logger } from '@/logging/logger.service'; import { SOURCE_CONTROL_SSH_FOLDER, diff --git a/packages/cli/src/environments/source-control/source-control.service.ee.ts b/packages/cli/src/environments/source-control/source-control.service.ee.ts index e010210262f62..8fcb1f35711fa 100644 --- a/packages/cli/src/environments/source-control/source-control.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control.service.ee.ts @@ -1,4 +1,5 @@ import { writeFileSync } from 'fs'; +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import path from 'path'; import type { PushResult } from 'simple-git'; @@ -10,7 +11,6 @@ import type { Variables } from '@/databases/entities/variables'; import { TagRepository } from '@/databases/repositories/tag.repository'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { EventService } from '@/events/event.service'; -import { Logger } from '@/logging/logger.service'; import { SOURCE_CONTROL_DEFAULT_EMAIL, diff --git a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.ts b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.ts index 4046855f30e0a..90049da1fff6a 100644 --- a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.ts +++ b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.ts @@ -1,8 +1,8 @@ +import { Logger } from 'n8n-core'; import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; import { Container } from 'typedi'; import type { EventDestinations } from '@/databases/entities/event-destinations'; -import { Logger } from '@/logging/logger.service'; import { MessageEventBusDestinationSentry } from './message-event-bus-destination-sentry.ee'; import { MessageEventBusDestinationSyslog } from './message-event-bus-destination-syslog.ee'; diff --git a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.ts b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.ts index 83db469d7913c..c0e7657e0fa95 100644 --- a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.ts +++ b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ +import { Logger } from 'n8n-core'; import type { MessageEventBusDestinationOptions, MessageEventBusDestinationSyslogOptions, @@ -7,8 +8,6 @@ import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; import syslog from 'syslog-client'; import Container from 'typedi'; -import { Logger } from '@/logging/logger.service'; - import { MessageEventBusDestination } from './message-event-bus-destination.ee'; import { eventMessageGenericDestinationTestEvent } from '../event-message-classes/event-message-generic'; import type { MessageEventBus, MessageWithCallback } from '../message-event-bus/message-event-bus'; diff --git a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination.ee.ts b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination.ee.ts index 7b65767b04ea7..c3aaf71173513 100644 --- a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination.ee.ts +++ b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination.ee.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import type { INodeCredentials, MessageEventBusDestinationOptions } from 'n8n-workflow'; import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; import { Container } from 'typedi'; @@ -5,7 +6,6 @@ import { v4 as uuid } from 'uuid'; import { EventDestinationsRepository } from '@/databases/repositories/event-destinations.repository'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import type { EventMessageTypes } from '../event-message-classes'; import type { AbstractEventMessage } from '../event-message-classes/abstract-event-message'; diff --git a/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer.ts b/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer.ts index 3f3cb50b185dd..c418035a70a2b 100644 --- a/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer.ts +++ b/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer.ts @@ -4,7 +4,7 @@ import { GlobalConfig } from '@n8n/config'; import { once as eventOnce } from 'events'; import { createReadStream, existsSync, rmSync } from 'fs'; import remove from 'lodash/remove'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { EventMessageTypeNames, jsonParse } from 'n8n-workflow'; import path, { parse } from 'path'; import readline from 'readline'; @@ -12,7 +12,6 @@ import Container from 'typedi'; import { Worker } from 'worker_threads'; import { inTest } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import type { EventMessageTypes } from '../event-message-classes'; import { isEventMessageOptions } from '../event-message-classes/abstract-event-message'; diff --git a/packages/cli/src/eventbus/message-event-bus/message-event-bus.ts b/packages/cli/src/eventbus/message-event-bus/message-event-bus.ts index 3cf5a5a5d0572..2cd35a596f811 100644 --- a/packages/cli/src/eventbus/message-event-bus/message-event-bus.ts +++ b/packages/cli/src/eventbus/message-event-bus/message-event-bus.ts @@ -5,6 +5,7 @@ import type { DeleteResult } from '@n8n/typeorm'; import { In } from '@n8n/typeorm'; import EventEmitter from 'events'; import uniqby from 'lodash/uniqBy'; +import { Logger } from 'n8n-core'; import type { MessageEventBusDestinationOptions } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -13,7 +14,6 @@ import { EventDestinationsRepository } from '@/databases/repositories/event-dest import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { Publisher } from '@/scaling/pubsub/publisher.service'; import { ExecutionRecoveryService } from '../../executions/execution-recovery.service'; diff --git a/packages/cli/src/execution-lifecycle-hooks/__tests__/save-execution-progress.test.ts b/packages/cli/src/execution-lifecycle-hooks/__tests__/save-execution-progress.test.ts index eedbf27c9e6eb..ac52cf3920228 100644 --- a/packages/cli/src/execution-lifecycle-hooks/__tests__/save-execution-progress.test.ts +++ b/packages/cli/src/execution-lifecycle-hooks/__tests__/save-execution-progress.test.ts @@ -1,11 +1,11 @@ import { ErrorReporter } from 'n8n-core'; +import { Logger } from 'n8n-core'; import type { IRunExecutionData, ITaskData, IWorkflowBase } from 'n8n-workflow'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { saveExecutionProgress } from '@/execution-lifecycle-hooks/save-execution-progress'; import * as fnModule from '@/execution-lifecycle-hooks/to-save-settings'; import type { IExecutionResponse } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { mockInstance } from '@test/mocking'; mockInstance(Logger); diff --git a/packages/cli/src/execution-lifecycle-hooks/restore-binary-data-id.ts b/packages/cli/src/execution-lifecycle-hooks/restore-binary-data-id.ts index d9a1a9a0e99c1..15ac8b905cb4c 100644 --- a/packages/cli/src/execution-lifecycle-hooks/restore-binary-data-id.ts +++ b/packages/cli/src/execution-lifecycle-hooks/restore-binary-data-id.ts @@ -1,10 +1,9 @@ -import { BinaryDataService } from 'n8n-core'; import type { BinaryData } from 'n8n-core'; +import { BinaryDataService, Logger } from 'n8n-core'; import type { IRun, WorkflowExecuteMode } from 'n8n-workflow'; import Container from 'typedi'; import config from '@/config'; -import { Logger } from '@/logging/logger.service'; /** * Whenever the execution ID is not available to the binary data service at the diff --git a/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts b/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts index c1de2646c0269..2047c9e82eade 100644 --- a/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts +++ b/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts @@ -1,10 +1,9 @@ -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import type { IRunExecutionData, ITaskData, IWorkflowBase } from 'n8n-workflow'; import { Container } from 'typedi'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { toSaveSettings } from '@/execution-lifecycle-hooks/to-save-settings'; -import { Logger } from '@/logging/logger.service'; export async function saveExecutionProgress( workflowData: IWorkflowBase, diff --git a/packages/cli/src/execution-lifecycle-hooks/shared/shared-hook-functions.ts b/packages/cli/src/execution-lifecycle-hooks/shared/shared-hook-functions.ts index 68fd528f14110..4c91222126cae 100644 --- a/packages/cli/src/execution-lifecycle-hooks/shared/shared-hook-functions.ts +++ b/packages/cli/src/execution-lifecycle-hooks/shared/shared-hook-functions.ts @@ -1,10 +1,10 @@ import pick from 'lodash/pick'; +import { Logger } from 'n8n-core'; import { ensureError, type ExecutionStatus, type IRun, type IWorkflowBase } from 'n8n-workflow'; import { Container } from 'typedi'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import type { IExecutionDb, UpdateExecutionPayload } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { ExecutionMetadataService } from '@/services/execution-metadata.service'; import { isWorkflowIdValid } from '@/utils'; diff --git a/packages/cli/src/executions/__tests__/execution-recovery.service.test.ts b/packages/cli/src/executions/__tests__/execution-recovery.service.test.ts index 115a1a52f60e8..0e6017a2bd395 100644 --- a/packages/cli/src/executions/__tests__/execution-recovery.service.test.ts +++ b/packages/cli/src/executions/__tests__/execution-recovery.service.test.ts @@ -22,7 +22,7 @@ import { setupMessages } from './utils'; describe('ExecutionRecoveryService', () => { const push = mockInstance(Push); - const instanceSettings = new InstanceSettings(mock()); + const instanceSettings = Container.get(InstanceSettings); let executionRecoveryService: ExecutionRecoveryService; let executionRepository: ExecutionRepository; diff --git a/packages/cli/src/executions/execution-recovery.service.ts b/packages/cli/src/executions/execution-recovery.service.ts index a10fc995a472d..f307ce0677f5c 100644 --- a/packages/cli/src/executions/execution-recovery.service.ts +++ b/packages/cli/src/executions/execution-recovery.service.ts @@ -1,5 +1,5 @@ import type { DateTime } from 'luxon'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { sleep } from 'n8n-workflow'; import type { IRun, ITaskData } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -10,7 +10,6 @@ import { NodeCrashedError } from '@/errors/node-crashed.error'; import { WorkflowCrashedError } from '@/errors/workflow-crashed.error'; import { EventService } from '@/events/event.service'; import type { IExecutionResponse } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { Push } from '@/push'; import { getWorkflowHooksMain } from '@/workflow-execute-additional-data'; // @TODO: Dependency cycle diff --git a/packages/cli/src/executions/execution.service.ts b/packages/cli/src/executions/execution.service.ts index 433955254f698..ffddb271649fa 100644 --- a/packages/cli/src/executions/execution.service.ts +++ b/packages/cli/src/executions/execution.service.ts @@ -1,5 +1,6 @@ import { GlobalConfig } from '@n8n/config'; import { validate as jsonSchemaValidate } from 'jsonschema'; +import { Logger } from 'n8n-core'; import type { ExecutionError, ExecutionStatus, @@ -38,7 +39,6 @@ import type { IWorkflowDb, } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { WaitTracker } from '@/wait-tracker'; import { WorkflowRunner } from '@/workflow-runner'; diff --git a/packages/cli/src/external-secrets/external-secrets-manager.ee.ts b/packages/cli/src/external-secrets/external-secrets-manager.ee.ts index 2de681a7d62be..d4adf17255554 100644 --- a/packages/cli/src/external-secrets/external-secrets-manager.ee.ts +++ b/packages/cli/src/external-secrets/external-secrets-manager.ee.ts @@ -1,4 +1,4 @@ -import { Cipher } from 'n8n-core'; +import { Cipher, Logger } from 'n8n-core'; import { jsonParse, type IDataObject, ApplicationError, ensureError } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -10,7 +10,6 @@ import type { SecretsProviderSettings, } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { Publisher } from '@/scaling/pubsub/publisher.service'; import { EXTERNAL_SECRETS_INITIAL_BACKOFF, EXTERNAL_SECRETS_MAX_BACKOFF } from './constants'; diff --git a/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts b/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts index 6c2c0669fb79a..629b3ad626bc2 100644 --- a/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts +++ b/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts @@ -1,10 +1,10 @@ +import { Logger } from 'n8n-core'; import type { INodeProperties } from 'n8n-workflow'; import Container from 'typedi'; import { UnknownAuthTypeError } from '@/errors/unknown-auth-type.error'; import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets/constants'; import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { AwsSecretsClient } from './aws-secrets-client'; import type { AwsSecretsManagerContext } from './types'; diff --git a/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts b/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts index 7961f21bad24b..01995d699012b 100644 --- a/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts +++ b/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts @@ -1,11 +1,11 @@ import type { SecretClient } from '@azure/keyvault-secrets'; +import { Logger } from 'n8n-core'; import { ensureError } from 'n8n-workflow'; import type { INodeProperties } from 'n8n-workflow'; import Container from 'typedi'; import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets/constants'; import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import type { AzureKeyVaultContext } from './types'; diff --git a/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts b/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts index c4bf71cb72169..ec29a281984c0 100644 --- a/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts +++ b/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts @@ -1,10 +1,10 @@ import type { SecretManagerServiceClient as GcpClient } from '@google-cloud/secret-manager'; +import { Logger } from 'n8n-core'; import { ensureError, jsonParse, type INodeProperties } from 'n8n-workflow'; import Container from 'typedi'; import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets/constants'; import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import type { GcpSecretsManagerContext, diff --git a/packages/cli/src/external-secrets/providers/vault.ts b/packages/cli/src/external-secrets/providers/vault.ts index 0f1e93a5da5cf..8030832376fe9 100644 --- a/packages/cli/src/external-secrets/providers/vault.ts +++ b/packages/cli/src/external-secrets/providers/vault.ts @@ -1,11 +1,11 @@ import type { AxiosInstance, AxiosResponse } from 'axios'; import axios from 'axios'; +import { Logger } from 'n8n-core'; import type { IDataObject, INodeProperties } from 'n8n-workflow'; import { Container } from 'typedi'; import type { SecretsProviderSettings, SecretsProviderState } from '@/interfaces'; import { SecretsProvider } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '../constants'; import { preferGet } from '../external-secrets-helper.ee'; diff --git a/packages/cli/src/help.ts b/packages/cli/src/help.ts index 8581483577402..168b9c907933e 100644 --- a/packages/cli/src/help.ts +++ b/packages/cli/src/help.ts @@ -1,6 +1,6 @@ import { Help } from '@oclif/core'; -import Container from 'typedi'; -import { Logger } from 'winston'; +import { Logger } from 'n8n-core'; +import { Container } from 'typedi'; // oclif expects a default export // eslint-disable-next-line import/no-default-export diff --git a/packages/cli/src/ldap/ldap.service.ee.ts b/packages/cli/src/ldap/ldap.service.ee.ts index b552db697401a..1445f56f13c35 100644 --- a/packages/cli/src/ldap/ldap.service.ee.ts +++ b/packages/cli/src/ldap/ldap.service.ee.ts @@ -2,7 +2,7 @@ import { QueryFailedError } from '@n8n/typeorm'; import type { Entry as LdapUser, ClientOptions } from 'ldapts'; import { Client } from 'ldapts'; -import { Cipher } from 'n8n-core'; +import { Cipher, Logger } from 'n8n-core'; import { ApplicationError, jsonParse } from 'n8n-workflow'; import type { ConnectionOptions } from 'tls'; import { Service } from 'typedi'; @@ -14,7 +14,6 @@ import { SettingsRepository } from '@/databases/repositories/settings.repository import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { EventService } from '@/events/event.service'; -import { Logger } from '@/logging/logger.service'; import { getCurrentAuthenticationMethod, isEmailCurrentAuthenticationMethod, diff --git a/packages/cli/src/license.ts b/packages/cli/src/license.ts index 2a3ae6fd6dee6..59804b6a7d0c4 100644 --- a/packages/cli/src/license.ts +++ b/packages/cli/src/license.ts @@ -1,13 +1,12 @@ import { GlobalConfig } from '@n8n/config'; import type { TEntitlement, TFeatures, TLicenseBlock } from '@n8n_io/license-sdk'; import { LicenseManager } from '@n8n_io/license-sdk'; -import { InstanceSettings, ObjectStoreService } from 'n8n-core'; +import { InstanceSettings, ObjectStoreService, Logger } from 'n8n-core'; import Container, { Service } from 'typedi'; import config from '@/config'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; import { OnShutdown } from '@/decorators/on-shutdown'; -import { Logger } from '@/logging/logger.service'; import { LicenseMetricsService } from '@/metrics/license-metrics.service'; import { diff --git a/packages/cli/src/license/license.service.ts b/packages/cli/src/license/license.service.ts index 1419d58b83572..750b42b432381 100644 --- a/packages/cli/src/license/license.service.ts +++ b/packages/cli/src/license/license.service.ts @@ -1,4 +1,5 @@ import axios, { AxiosError } from 'axios'; +import { Logger } from 'n8n-core'; import { ensureError } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -7,7 +8,6 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { EventService } from '@/events/event.service'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { UrlService } from '@/services/url.service'; type LicenseError = Error & { errorId?: keyof typeof LicenseErrors }; diff --git a/packages/cli/src/load-nodes-and-credentials.ts b/packages/cli/src/load-nodes-and-credentials.ts index db62e8415ea71..e462bd4157861 100644 --- a/packages/cli/src/load-nodes-and-credentials.ts +++ b/packages/cli/src/load-nodes-and-credentials.ts @@ -11,6 +11,7 @@ import { LazyPackageDirectoryLoader, UnrecognizedCredentialTypeError, UnrecognizedNodeTypeError, + Logger, } from 'n8n-core'; import type { KnownNodesAndCredentials, @@ -36,7 +37,6 @@ import { CLI_DIR, inE2ETests, } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import { isContainedWithin } from '@/utils/path-util'; interface LoadedNodesAndCredentials { diff --git a/packages/cli/src/logging/constants.ts b/packages/cli/src/logging/constants.ts deleted file mode 100644 index 107327694b1b9..0000000000000 --- a/packages/cli/src/logging/constants.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const noOp = () => {}; - -export const LOG_LEVELS = ['error', 'warn', 'info', 'debug', 'silent'] as const; diff --git a/packages/cli/src/logging/types.ts b/packages/cli/src/logging/types.ts deleted file mode 100644 index bb01834326090..0000000000000 --- a/packages/cli/src/logging/types.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { LogScope } from '@n8n/config'; - -import type { LOG_LEVELS } from './constants'; - -export type LogLevel = (typeof LOG_LEVELS)[number]; - -export type LogMetadata = { - [key: string]: unknown; - scopes?: LogScope[]; - file?: string; - function?: string; -}; - -export type LogLocationMetadata = Pick; diff --git a/packages/cli/src/manual-execution.service.ts b/packages/cli/src/manual-execution.service.ts index 65174d20b50f8..c6749696feb6b 100644 --- a/packages/cli/src/manual-execution.service.ts +++ b/packages/cli/src/manual-execution.service.ts @@ -4,6 +4,7 @@ import { filterDisabledNodes, recreateNodeExecutionStack, WorkflowExecute, + Logger, } from 'n8n-core'; import type { IPinData, @@ -16,8 +17,6 @@ import type { import type PCancelable from 'p-cancelable'; import { Service } from 'typedi'; -import { Logger } from '@/logging/logger.service'; - @Service() export class ManualExecutionService { constructor(private readonly logger: Logger) {} diff --git a/packages/cli/src/push/__tests__/websocket.push.test.ts b/packages/cli/src/push/__tests__/websocket.push.test.ts index fd1e2f27a0b52..c13a319ebf27a 100644 --- a/packages/cli/src/push/__tests__/websocket.push.test.ts +++ b/packages/cli/src/push/__tests__/websocket.push.test.ts @@ -1,10 +1,10 @@ import type { PushMessage } from '@n8n/api-types'; import { EventEmitter } from 'events'; +import { Logger } from 'n8n-core'; import { Container } from 'typedi'; import type WebSocket from 'ws'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logging/logger.service'; import { WebSocketPush } from '@/push/websocket.push'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/push/abstract.push.ts b/packages/cli/src/push/abstract.push.ts index 574f8a0def056..b1c4514d8d6f6 100644 --- a/packages/cli/src/push/abstract.push.ts +++ b/packages/cli/src/push/abstract.push.ts @@ -1,10 +1,9 @@ import type { PushMessage } from '@n8n/api-types'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import { assert, jsonStringify } from 'n8n-workflow'; import { Service } from 'typedi'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logging/logger.service'; import type { OnPushMessage } from '@/push/types'; import { TypedEmitter } from '@/typed-emitter'; diff --git a/packages/cli/src/response-helper.ts b/packages/cli/src/response-helper.ts index 0e70aa312f72c..f7f448cc9dc6f 100644 --- a/packages/cli/src/response-helper.ts +++ b/packages/cli/src/response-helper.ts @@ -1,13 +1,12 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import type { Request, Response } from 'express'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import { FORM_TRIGGER_PATH_IDENTIFIER, NodeApiError } from 'n8n-workflow'; import { Readable } from 'node:stream'; import picocolors from 'picocolors'; import Container from 'typedi'; import { inDevelopment } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import { ResponseError } from './errors/response-errors/abstract/response.error'; diff --git a/packages/cli/src/runners/__tests__/task-runner-process-restart-loop-detector.test.ts b/packages/cli/src/runners/__tests__/task-runner-process-restart-loop-detector.test.ts index 61cfb8b8e85cf..31abac807a2bf 100644 --- a/packages/cli/src/runners/__tests__/task-runner-process-restart-loop-detector.test.ts +++ b/packages/cli/src/runners/__tests__/task-runner-process-restart-loop-detector.test.ts @@ -1,7 +1,7 @@ import { TaskRunnersConfig } from '@n8n/config'; import { mock } from 'jest-mock-extended'; +import type { Logger } from 'n8n-core'; -import type { Logger } from '@/logging/logger.service'; import type { TaskRunnerAuthService } from '@/runners/auth/task-runner-auth.service'; import { TaskRunnerRestartLoopError } from '@/runners/errors/task-runner-restart-loop-error'; import { RunnerLifecycleEvents } from '@/runners/runner-lifecycle-events'; diff --git a/packages/cli/src/runners/__tests__/task-runner-process.test.ts b/packages/cli/src/runners/__tests__/task-runner-process.test.ts index 85dbaa6930884..42d6794287231 100644 --- a/packages/cli/src/runners/__tests__/task-runner-process.test.ts +++ b/packages/cli/src/runners/__tests__/task-runner-process.test.ts @@ -1,8 +1,8 @@ import { TaskRunnersConfig } from '@n8n/config'; import { mock } from 'jest-mock-extended'; +import { Logger } from 'n8n-core'; import type { ChildProcess, SpawnOptions } from 'node:child_process'; -import { Logger } from '@/logging/logger.service'; import type { TaskRunnerAuthService } from '@/runners/auth/task-runner-auth.service'; import { TaskRunnerProcess } from '@/runners/task-runner-process'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/runners/runner-ws-server.ts b/packages/cli/src/runners/runner-ws-server.ts index 8ea3a7edbe547..53b8f18cf8f71 100644 --- a/packages/cli/src/runners/runner-ws-server.ts +++ b/packages/cli/src/runners/runner-ws-server.ts @@ -1,11 +1,11 @@ import { TaskRunnersConfig } from '@n8n/config'; import type { BrokerMessage, RunnerMessage } from '@n8n/task-runner'; +import { Logger } from 'n8n-core'; import { ApplicationError, jsonStringify } from 'n8n-workflow'; import { Service } from 'typedi'; import type WebSocket from 'ws'; import { Time, WsStatusCodes } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import { DefaultTaskRunnerDisconnectAnalyzer } from './default-task-runner-disconnect-analyzer'; import { RunnerLifecycleEvents } from './runner-lifecycle-events'; diff --git a/packages/cli/src/runners/task-broker.service.ts b/packages/cli/src/runners/task-broker.service.ts index e52992d38eed8..ebbed80860b50 100644 --- a/packages/cli/src/runners/task-broker.service.ts +++ b/packages/cli/src/runners/task-broker.service.ts @@ -5,13 +5,13 @@ import type { RunnerMessage, TaskResultData, } from '@n8n/task-runner'; +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import { nanoid } from 'nanoid'; import { Service } from 'typedi'; import config from '@/config'; import { Time } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import { TaskDeferredError, TaskRejectError } from './errors'; import { TaskRunnerTimeoutError } from './errors/task-runner-timeout.error'; diff --git a/packages/cli/src/runners/task-runner-module.ts b/packages/cli/src/runners/task-runner-module.ts index 434daa066a35c..97f3f4e481c71 100644 --- a/packages/cli/src/runners/task-runner-module.ts +++ b/packages/cli/src/runners/task-runner-module.ts @@ -1,11 +1,10 @@ import { TaskRunnersConfig } from '@n8n/config'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import { sleep } from 'n8n-workflow'; import * as a from 'node:assert/strict'; import Container, { Service } from 'typedi'; import { OnShutdown } from '@/decorators/on-shutdown'; -import { Logger } from '@/logging/logger.service'; import type { TaskRunnerRestartLoopError } from '@/runners/errors/task-runner-restart-loop-error'; import type { TaskRunnerProcess } from '@/runners/task-runner-process'; import { TaskRunnerProcessRestartLoopDetector } from '@/runners/task-runner-process-restart-loop-detector'; diff --git a/packages/cli/src/runners/task-runner-process.ts b/packages/cli/src/runners/task-runner-process.ts index 2716383f17430..668792994212e 100644 --- a/packages/cli/src/runners/task-runner-process.ts +++ b/packages/cli/src/runners/task-runner-process.ts @@ -1,11 +1,11 @@ import { TaskRunnersConfig } from '@n8n/config'; +import { Logger } from 'n8n-core'; import * as a from 'node:assert/strict'; import { spawn } from 'node:child_process'; import * as process from 'node:process'; import { Service } from 'typedi'; import { OnShutdown } from '@/decorators/on-shutdown'; -import { Logger } from '@/logging/logger.service'; import { TaskRunnerAuthService } from './auth/task-runner-auth.service'; import { forwardToLogger } from './forward-to-logger'; diff --git a/packages/cli/src/runners/task-runner-server.ts b/packages/cli/src/runners/task-runner-server.ts index 2b1f481b0e338..bbe1d7cd6adeb 100644 --- a/packages/cli/src/runners/task-runner-server.ts +++ b/packages/cli/src/runners/task-runner-server.ts @@ -1,6 +1,7 @@ import { GlobalConfig } from '@n8n/config'; import compression from 'compression'; import express from 'express'; +import { Logger } from 'n8n-core'; import * as a from 'node:assert/strict'; import { randomBytes } from 'node:crypto'; import { ServerResponse, type Server, createServer as createHttpServer } from 'node:http'; @@ -10,7 +11,6 @@ import { Service } from 'typedi'; import { Server as WSServer } from 'ws'; import { inTest } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import { bodyParser, rawBodyReader } from '@/middlewares'; import { send } from '@/response-helper'; import { TaskRunnerAuthController } from '@/runners/auth/task-runner-auth.controller'; diff --git a/packages/cli/src/scaling/job-processor.ts b/packages/cli/src/scaling/job-processor.ts index 51b86c3922301..5e760e40c1063 100644 --- a/packages/cli/src/scaling/job-processor.ts +++ b/packages/cli/src/scaling/job-processor.ts @@ -1,5 +1,5 @@ import type { RunningJobSummary } from '@n8n/api-types'; -import { ErrorReporter, InstanceSettings, WorkflowExecute } from 'n8n-core'; +import { ErrorReporter, InstanceSettings, WorkflowExecute, Logger } from 'n8n-core'; import type { ExecutionStatus, IExecuteResponsePromiseData, IRun } from 'n8n-workflow'; import { BINARY_ENCODING, ApplicationError, Workflow } from 'n8n-workflow'; import type PCancelable from 'p-cancelable'; @@ -8,7 +8,6 @@ import { Service } from 'typedi'; import config from '@/config'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; diff --git a/packages/cli/src/scaling/multi-main-setup.ee.ts b/packages/cli/src/scaling/multi-main-setup.ee.ts index dab9f17cc6dc9..1a2554965c24e 100644 --- a/packages/cli/src/scaling/multi-main-setup.ee.ts +++ b/packages/cli/src/scaling/multi-main-setup.ee.ts @@ -1,10 +1,9 @@ import { GlobalConfig } from '@n8n/config'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { Service } from 'typedi'; import config from '@/config'; import { Time } from '@/constants'; -import { Logger } from '@/logging/logger.service'; import { Publisher } from '@/scaling/pubsub/publisher.service'; import { RedisClientService } from '@/services/redis-client.service'; import { TypedEmitter } from '@/typed-emitter'; diff --git a/packages/cli/src/scaling/pubsub/publisher.service.ts b/packages/cli/src/scaling/pubsub/publisher.service.ts index 4723b1d37dea7..551d1b6caf02f 100644 --- a/packages/cli/src/scaling/pubsub/publisher.service.ts +++ b/packages/cli/src/scaling/pubsub/publisher.service.ts @@ -1,10 +1,9 @@ import type { Redis as SingleNodeClient, Cluster as MultiNodeClient } from 'ioredis'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; +import type { LogMetadata } from 'n8n-workflow'; import { Service } from 'typedi'; import config from '@/config'; -import { Logger } from '@/logging/logger.service'; -import type { LogMetadata } from '@/logging/types'; import { RedisClientService } from '@/services/redis-client.service'; import type { PubSub } from './pubsub.types'; diff --git a/packages/cli/src/scaling/pubsub/subscriber.service.ts b/packages/cli/src/scaling/pubsub/subscriber.service.ts index 0ce343c139b0a..c2d5498243006 100644 --- a/packages/cli/src/scaling/pubsub/subscriber.service.ts +++ b/packages/cli/src/scaling/pubsub/subscriber.service.ts @@ -1,13 +1,12 @@ import type { Redis as SingleNodeClient, Cluster as MultiNodeClient } from 'ioredis'; import debounce from 'lodash/debounce'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { jsonParse } from 'n8n-workflow'; +import type { LogMetadata } from 'n8n-workflow'; import { Service } from 'typedi'; import config from '@/config'; import { EventService } from '@/events/event.service'; -import { Logger } from '@/logging/logger.service'; -import type { LogMetadata } from '@/logging/types'; import { RedisClientService } from '@/services/redis-client.service'; import type { PubSub } from './pubsub.types'; diff --git a/packages/cli/src/scaling/scaling.service.ts b/packages/cli/src/scaling/scaling.service.ts index ebc8e4499ca90..5896e2976be42 100644 --- a/packages/cli/src/scaling/scaling.service.ts +++ b/packages/cli/src/scaling/scaling.service.ts @@ -1,5 +1,5 @@ import { GlobalConfig } from '@n8n/config'; -import { ErrorReporter, InstanceSettings } from 'n8n-core'; +import { ErrorReporter, InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, BINARY_ENCODING, sleep, jsonStringify, ensureError } from 'n8n-workflow'; import type { IExecuteResponsePromiseData } from 'n8n-workflow'; import { strict } from 'node:assert'; @@ -12,7 +12,6 @@ import { ExecutionRepository } from '@/databases/repositories/execution.reposito import { OnShutdown } from '@/decorators/on-shutdown'; import { MaxStalledCountError } from '@/errors/max-stalled-count.error'; import { EventService } from '@/events/event.service'; -import { Logger } from '@/logging/logger.service'; import { OrchestrationService } from '@/services/orchestration.service'; import { assertNever } from '@/utils'; diff --git a/packages/cli/src/scaling/worker-server.ts b/packages/cli/src/scaling/worker-server.ts index ee622d789cbb9..8112f3a4f5bdb 100644 --- a/packages/cli/src/scaling/worker-server.ts +++ b/packages/cli/src/scaling/worker-server.ts @@ -1,7 +1,7 @@ import { GlobalConfig } from '@n8n/config'; import type { Application } from 'express'; import express from 'express'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { strict as assert } from 'node:assert'; import http from 'node:http'; import type { Server } from 'node:http'; @@ -13,7 +13,6 @@ import { CredentialsOverwritesAlreadySetError } from '@/errors/credentials-overw import { NonJsonBodyError } from '@/errors/non-json-body.error'; import { ExternalHooks } from '@/external-hooks'; import type { ICredentialsOverwrite } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { PrometheusMetricsService } from '@/metrics/prometheus-metrics.service'; import { rawBodyReader, bodyParser } from '@/middlewares'; import * as ResponseHelper from '@/response-helper'; diff --git a/packages/cli/src/security-audit/risk-reporters/instance-risk-reporter.ts b/packages/cli/src/security-audit/risk-reporters/instance-risk-reporter.ts index 37113e4c40489..92874e87f05e1 100644 --- a/packages/cli/src/security-audit/risk-reporters/instance-risk-reporter.ts +++ b/packages/cli/src/security-audit/risk-reporters/instance-risk-reporter.ts @@ -1,12 +1,11 @@ import { GlobalConfig } from '@n8n/config'; import axios from 'axios'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { Service } from 'typedi'; import config from '@/config'; import { getN8nPackageJson, inDevelopment } from '@/constants'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import { Logger } from '@/logging/logger.service'; import { isApiEnabled } from '@/public-api'; import { ENV_VARS_DOCS_URL, diff --git a/packages/cli/src/services/active-workflows.service.ts b/packages/cli/src/services/active-workflows.service.ts index 61aa875d1a61a..d2c50c74c2144 100644 --- a/packages/cli/src/services/active-workflows.service.ts +++ b/packages/cli/src/services/active-workflows.service.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import { Service } from 'typedi'; import { ActivationErrorsService } from '@/activation-errors.service'; @@ -5,7 +6,6 @@ import type { User } from '@/databases/entities/user'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { Logger } from '@/logging/logger.service'; @Service() export class ActiveWorkflowsService { diff --git a/packages/cli/src/services/community-packages.service.ts b/packages/cli/src/services/community-packages.service.ts index 9f09d0c310def..a94b4d5c4f784 100644 --- a/packages/cli/src/services/community-packages.service.ts +++ b/packages/cli/src/services/community-packages.service.ts @@ -2,8 +2,8 @@ import { GlobalConfig } from '@n8n/config'; import axios from 'axios'; import { exec } from 'child_process'; import { access as fsAccess, mkdir as fsMkdir } from 'fs/promises'; -import { InstanceSettings } from 'n8n-core'; import type { PackageDirectoryLoader } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, type PublicInstalledPackage } from 'n8n-workflow'; import { Service } from 'typedi'; import { promisify } from 'util'; @@ -22,7 +22,6 @@ import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; import type { CommunityPackages } from '@/interfaces'; import { License } from '@/license'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; -import { Logger } from '@/logging/logger.service'; import { Publisher } from '@/scaling/pubsub/publisher.service'; import { toError } from '@/utils'; diff --git a/packages/cli/src/services/credentials-tester.service.ts b/packages/cli/src/services/credentials-tester.service.ts index 6ae7201ac0558..0709d77e06bb5 100644 --- a/packages/cli/src/services/credentials-tester.service.ts +++ b/packages/cli/src/services/credentials-tester.service.ts @@ -4,7 +4,13 @@ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-call */ import get from 'lodash/get'; -import { ErrorReporter, NodeExecuteFunctions, RoutingNode, isObjectLiteral } from 'n8n-core'; +import { + ErrorReporter, + Logger, + NodeExecuteFunctions, + RoutingNode, + isObjectLiteral, +} from 'n8n-core'; import type { ICredentialsDecrypted, ICredentialTestFunction, @@ -28,7 +34,6 @@ import { Service } from 'typedi'; import { CredentialTypes } from '@/credential-types'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; diff --git a/packages/cli/src/services/frontend.service.ts b/packages/cli/src/services/frontend.service.ts index 1645e98304d56..75fe36358faf3 100644 --- a/packages/cli/src/services/frontend.service.ts +++ b/packages/cli/src/services/frontend.service.ts @@ -3,7 +3,7 @@ import { GlobalConfig, FrontendConfig, SecurityConfig } from '@n8n/config'; import { createWriteStream } from 'fs'; import { mkdir } from 'fs/promises'; import uniq from 'lodash/uniq'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import type { ICredentialType, INodeTypeBaseDescription } from 'n8n-workflow'; import path from 'path'; import { Container, Service } from 'typedi'; @@ -16,7 +16,6 @@ import { getVariablesLimit } from '@/environments/variables/environment-helpers' import { getLdapLoginLabel } from '@/ldap/helpers.ee'; import { License } from '@/license'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; -import { Logger } from '@/logging/logger.service'; import { isApiEnabled } from '@/public-api'; import type { CommunityPackagesService } from '@/services/community-packages.service'; import { getSamlLoginLabel } from '@/sso/saml/saml-helpers'; diff --git a/packages/cli/src/services/import.service.ts b/packages/cli/src/services/import.service.ts index 2402863bab645..4f63357dd67a9 100644 --- a/packages/cli/src/services/import.service.ts +++ b/packages/cli/src/services/import.service.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import { type INode, type INodeCredentialsDetails } from 'n8n-workflow'; import { Service } from 'typedi'; import { v4 as uuid } from 'uuid'; @@ -11,7 +12,6 @@ import { CredentialsRepository } from '@/databases/repositories/credentials.repo import { TagRepository } from '@/databases/repositories/tag.repository'; import * as Db from '@/db'; import type { ICredentialsDb } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { replaceInvalidCredentials } from '@/workflow-helpers'; @Service() diff --git a/packages/cli/src/services/pruning/pruning.service.ts b/packages/cli/src/services/pruning/pruning.service.ts index aad8c5490f340..15d81dc48ec0b 100644 --- a/packages/cli/src/services/pruning/pruning.service.ts +++ b/packages/cli/src/services/pruning/pruning.service.ts @@ -1,5 +1,5 @@ import { ExecutionsConfig } from '@n8n/config'; -import { BinaryDataService, InstanceSettings } from 'n8n-core'; +import { BinaryDataService, InstanceSettings, Logger } from 'n8n-core'; import { ensureError } from 'n8n-workflow'; import { strict } from 'node:assert'; import { Service } from 'typedi'; @@ -8,7 +8,6 @@ import { Time } from '@/constants'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { connectionState as dbConnectionState } from '@/db'; import { OnShutdown } from '@/decorators/on-shutdown'; -import { Logger } from '@/logging/logger.service'; import { OrchestrationService } from '../orchestration.service'; diff --git a/packages/cli/src/services/redis-client.service.ts b/packages/cli/src/services/redis-client.service.ts index c58453016509f..894d3af67102d 100644 --- a/packages/cli/src/services/redis-client.service.ts +++ b/packages/cli/src/services/redis-client.service.ts @@ -1,10 +1,10 @@ import { GlobalConfig } from '@n8n/config'; import ioRedis from 'ioredis'; import type { Cluster, RedisOptions } from 'ioredis'; +import { Logger } from 'n8n-core'; import { Service } from 'typedi'; import { Debounce } from '@/decorators/debounce'; -import { Logger } from '@/logging/logger.service'; import { TypedEmitter } from '@/typed-emitter'; import type { RedisClientType } from '../scaling/redis/redis.types'; diff --git a/packages/cli/src/services/user.service.ts b/packages/cli/src/services/user.service.ts index e47dd026b0769..3d2cb304719cb 100644 --- a/packages/cli/src/services/user.service.ts +++ b/packages/cli/src/services/user.service.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import type { IUserSettings } from 'n8n-workflow'; import { ApplicationError } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -7,7 +8,6 @@ import { UserRepository } from '@/databases/repositories/user.repository'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { EventService } from '@/events/event.service'; import type { Invitation, PublicUser } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import type { PostHogClient } from '@/posthog'; import type { UserRequest } from '@/requests'; import { UrlService } from '@/services/url.service'; diff --git a/packages/cli/src/services/workflow-statistics.service.ts b/packages/cli/src/services/workflow-statistics.service.ts index 53cbac50947f8..9c0282eb850b0 100644 --- a/packages/cli/src/services/workflow-statistics.service.ts +++ b/packages/cli/src/services/workflow-statistics.service.ts @@ -1,10 +1,10 @@ +import { Logger } from 'n8n-core'; import type { INode, IRun, IWorkflowBase } from 'n8n-workflow'; import { Service } from 'typedi'; import { StatisticsNames } from '@/databases/entities/workflow-statistics'; import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository'; import { EventService } from '@/events/event.service'; -import { Logger } from '@/logging/logger.service'; import { UserService } from '@/services/user.service'; import { TypedEmitter } from '@/typed-emitter'; diff --git a/packages/cli/src/shutdown/shutdown.service.ts b/packages/cli/src/shutdown/shutdown.service.ts index 8ff8570757b86..1597b2a27f43c 100644 --- a/packages/cli/src/shutdown/shutdown.service.ts +++ b/packages/cli/src/shutdown/shutdown.service.ts @@ -1,9 +1,9 @@ import { type Class, ErrorReporter } from 'n8n-core'; +import { Logger } from 'n8n-core'; import { ApplicationError, assert } from 'n8n-workflow'; import { Container, Service } from 'typedi'; import { LOWEST_SHUTDOWN_PRIORITY, HIGHEST_SHUTDOWN_PRIORITY } from '@/constants'; -import { Logger } from '@/logging/logger.service'; type HandlerFn = () => Promise | void; export type ServiceClass = Class>; diff --git a/packages/cli/src/sso/saml/__tests__/saml-validator.test.ts b/packages/cli/src/sso/saml/__tests__/saml-validator.test.ts index 8594676ab2999..563c7934ea251 100644 --- a/packages/cli/src/sso/saml/__tests__/saml-validator.test.ts +++ b/packages/cli/src/sso/saml/__tests__/saml-validator.test.ts @@ -1,4 +1,5 @@ -import { Logger } from '@/logging/logger.service'; +import { Logger } from 'n8n-core'; + import { mockInstance } from '@test/mocking'; import { validateMetadata, validateResponse } from '../saml-validator'; diff --git a/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts b/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts index 8bd5e32da20a5..708592e8e7c97 100644 --- a/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts +++ b/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts @@ -1,9 +1,9 @@ import type express from 'express'; import { mock } from 'jest-mock-extended'; +import { Logger } from 'n8n-core'; import type { IdentityProviderInstance, ServiceProviderInstance } from 'samlify'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { Logger } from '@/logging/logger.service'; import { UrlService } from '@/services/url.service'; import * as samlHelpers from '@/sso/saml/saml-helpers'; import { SamlService } from '@/sso/saml/saml.service.ee'; diff --git a/packages/cli/src/sso/saml/saml-validator.ts b/packages/cli/src/sso/saml/saml-validator.ts index 07e9853f90044..582fe624a5d88 100644 --- a/packages/cli/src/sso/saml/saml-validator.ts +++ b/packages/cli/src/sso/saml/saml-validator.ts @@ -1,8 +1,7 @@ +import { Logger } from 'n8n-core'; import { Container } from 'typedi'; import type { XMLFileInfo } from 'xmllint-wasm'; -import { Logger } from '@/logging/logger.service'; - let xmlMetadata: XMLFileInfo; let xmlProtocol: XMLFileInfo; diff --git a/packages/cli/src/sso/saml/saml.service.ee.ts b/packages/cli/src/sso/saml/saml.service.ee.ts index 3672c8fe6ff23..2944d9adf1e4d 100644 --- a/packages/cli/src/sso/saml/saml.service.ee.ts +++ b/packages/cli/src/sso/saml/saml.service.ee.ts @@ -1,6 +1,7 @@ import axios from 'axios'; import type express from 'express'; import https from 'https'; +import { Logger } from 'n8n-core'; import { ApplicationError, jsonParse } from 'n8n-workflow'; import type { IdentityProviderInstance, ServiceProviderInstance } from 'samlify'; import type { BindingContext, PostBindingContext } from 'samlify/types/src/entity'; @@ -12,7 +13,6 @@ import { SettingsRepository } from '@/databases/repositories/settings.repository import { UserRepository } from '@/databases/repositories/user.repository'; import { AuthError } from '@/errors/response-errors/auth.error'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { Logger } from '@/logging/logger.service'; import { UrlService } from '@/services/url.service'; import { SAML_PREFERENCES_DB_KEY } from './constants'; diff --git a/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts b/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts index 6c64fc0b3a23f..0415977e2e10f 100644 --- a/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts +++ b/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts @@ -1,10 +1,10 @@ import { GlobalConfig } from '@n8n/config'; +import { Logger } from 'n8n-core'; import { type Workflow, type INode, type WorkflowSettings } from 'n8n-workflow'; import { Service } from 'typedi'; import type { Project } from '@/databases/entities/project'; import { SubworkflowPolicyDenialError } from '@/errors/subworkflow-policy-denial.error'; -import { Logger } from '@/logging/logger.service'; import { AccessService } from '@/services/access.service'; import { OwnershipService } from '@/services/ownership.service'; import { UrlService } from '@/services/url.service'; diff --git a/packages/cli/src/telemetry/index.ts b/packages/cli/src/telemetry/index.ts index a8d39d898ee8a..e8099e32cbf36 100644 --- a/packages/cli/src/telemetry/index.ts +++ b/packages/cli/src/telemetry/index.ts @@ -1,7 +1,7 @@ import { GlobalConfig } from '@n8n/config'; import type RudderStack from '@rudderstack/rudder-sdk-node'; import axios from 'axios'; -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import type { ITelemetryTrackProperties } from 'n8n-workflow'; import { Container, Service } from 'typedi'; @@ -13,7 +13,6 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository import { OnShutdown } from '@/decorators/on-shutdown'; import type { IExecutionTrackProperties } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { PostHogClient } from '@/posthog'; import { SourceControlPreferencesService } from '../environments/source-control/source-control-preferences.service.ee'; diff --git a/packages/cli/src/user-management/email/node-mailer.ts b/packages/cli/src/user-management/email/node-mailer.ts index a35ab77318456..4f4dc4f8953a8 100644 --- a/packages/cli/src/user-management/email/node-mailer.ts +++ b/packages/cli/src/user-management/email/node-mailer.ts @@ -1,14 +1,12 @@ import { GlobalConfig } from '@n8n/config'; import { pick } from 'lodash'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import path from 'node:path'; import type { Transporter } from 'nodemailer'; import { createTransport } from 'nodemailer'; import type SMTPConnection from 'nodemailer/lib/smtp-connection'; import { Service } from 'typedi'; -import { Logger } from '@/logging/logger.service'; - import type { MailData, SendEmailResult } from './interfaces'; @Service() diff --git a/packages/cli/src/user-management/email/user-management-mailer.ts b/packages/cli/src/user-management/email/user-management-mailer.ts index 3acddad185589..25794cec8d6dc 100644 --- a/packages/cli/src/user-management/email/user-management-mailer.ts +++ b/packages/cli/src/user-management/email/user-management-mailer.ts @@ -2,6 +2,7 @@ import { GlobalConfig } from '@n8n/config'; import { existsSync } from 'fs'; import { readFile } from 'fs/promises'; import Handlebars from 'handlebars'; +import { Logger } from 'n8n-core'; import { join as pathJoin } from 'path'; import { Container, Service } from 'typedi'; @@ -11,7 +12,6 @@ import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { UserRepository } from '@/databases/repositories/user.repository'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { EventService } from '@/events/event.service'; -import { Logger } from '@/logging/logger.service'; import { UrlService } from '@/services/url.service'; import { toError } from '@/utils'; diff --git a/packages/cli/src/wait-tracker.ts b/packages/cli/src/wait-tracker.ts index f42905ace1978..02480110ae9f2 100644 --- a/packages/cli/src/wait-tracker.ts +++ b/packages/cli/src/wait-tracker.ts @@ -1,10 +1,9 @@ -import { InstanceSettings } from 'n8n-core'; +import { InstanceSettings, Logger } from 'n8n-core'; import { ApplicationError, type IWorkflowExecutionDataProcess } from 'n8n-workflow'; import { Service } from 'typedi'; import { ActiveExecutions } from '@/active-executions'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { Logger } from '@/logging/logger.service'; import { OrchestrationService } from '@/services/orchestration.service'; import { OwnershipService } from '@/services/ownership.service'; import { WorkflowRunner } from '@/workflow-runner'; diff --git a/packages/cli/src/webhooks/live-webhooks.ts b/packages/cli/src/webhooks/live-webhooks.ts index 6d6fc9161de2c..1ebfef347033d 100644 --- a/packages/cli/src/webhooks/live-webhooks.ts +++ b/packages/cli/src/webhooks/live-webhooks.ts @@ -1,4 +1,5 @@ import type { Response } from 'express'; +import { Logger } from 'n8n-core'; import { Workflow, CHAT_TRIGGER_NODE_TYPE } from 'n8n-workflow'; import type { INode, IWebhookData, IHttpRequestMethods } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -6,7 +7,6 @@ import { Service } from 'typedi'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { WebhookNotFoundError } from '@/errors/response-errors/webhook-not-found.error'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import * as WebhookHelpers from '@/webhooks/webhook-helpers'; import { WebhookService } from '@/webhooks/webhook.service'; diff --git a/packages/cli/src/webhooks/waiting-webhooks.ts b/packages/cli/src/webhooks/waiting-webhooks.ts index 63557091893b0..ed2f8404bcaac 100644 --- a/packages/cli/src/webhooks/waiting-webhooks.ts +++ b/packages/cli/src/webhooks/waiting-webhooks.ts @@ -1,4 +1,5 @@ import type express from 'express'; +import { Logger } from 'n8n-core'; import { FORM_NODE_TYPE, type INodes, @@ -13,7 +14,6 @@ import { ExecutionRepository } from '@/databases/repositories/execution.reposito import { ConflictError } from '@/errors/response-errors/conflict.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import type { IExecutionResponse, IWorkflowDb } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import * as WebhookHelpers from '@/webhooks/webhook-helpers'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; diff --git a/packages/cli/src/webhooks/webhook-helpers.ts b/packages/cli/src/webhooks/webhook-helpers.ts index 665708988171c..51b81fad8371d 100644 --- a/packages/cli/src/webhooks/webhook-helpers.ts +++ b/packages/cli/src/webhooks/webhook-helpers.ts @@ -9,7 +9,7 @@ import { GlobalConfig } from '@n8n/config'; import type express from 'express'; import get from 'lodash/get'; -import { BinaryDataService, ErrorReporter } from 'n8n-core'; +import { BinaryDataService, ErrorReporter, Logger } from 'n8n-core'; import type { IBinaryData, IBinaryKeyData, @@ -46,7 +46,6 @@ import { InternalServerError } from '@/errors/response-errors/internal-server.er import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { UnprocessableRequestError } from '@/errors/response-errors/unprocessable.error'; import type { IWorkflowDb } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { parseBody } from '@/middlewares'; import { OwnershipService } from '@/services/ownership.service'; import { WorkflowStatisticsService } from '@/services/workflow-statistics.service'; diff --git a/packages/cli/src/webhooks/webhook.service.ts b/packages/cli/src/webhooks/webhook.service.ts index 80b12b04cd897..f571c9450bedc 100644 --- a/packages/cli/src/webhooks/webhook.service.ts +++ b/packages/cli/src/webhooks/webhook.service.ts @@ -1,4 +1,4 @@ -import { HookContext, WebhookContext } from 'n8n-core'; +import { HookContext, WebhookContext, Logger } from 'n8n-core'; import { ApplicationError, Node, NodeHelpers } from 'n8n-workflow'; import type { IHttpRequestMethods, @@ -16,7 +16,6 @@ import { Service } from 'typedi'; import type { WebhookEntity } from '@/databases/entities/webhook-entity'; import { WebhookRepository } from '@/databases/repositories/webhook.repository'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { CacheService } from '@/services/cache/cache.service'; diff --git a/packages/cli/src/workflow-execute-additional-data.ts b/packages/cli/src/workflow-execute-additional-data.ts index 29c8d67502f80..bf97ce0a3fba7 100644 --- a/packages/cli/src/workflow-execute-additional-data.ts +++ b/packages/cli/src/workflow-execute-additional-data.ts @@ -5,7 +5,7 @@ import type { PushMessage, PushType } from '@n8n/api-types'; import { GlobalConfig } from '@n8n/config'; import { stringify } from 'flatted'; -import { ErrorReporter, WorkflowExecute, isObjectLiteral } from 'n8n-core'; +import { ErrorReporter, Logger, WorkflowExecute, isObjectLiteral } from 'n8n-core'; import { ApplicationError, NodeOperationError, Workflow, WorkflowHooks } from 'n8n-workflow'; import type { IDataObject, @@ -58,7 +58,6 @@ import { updateExistingExecution, } from './execution-lifecycle-hooks/shared/shared-hook-functions'; import { toSaveSettings } from './execution-lifecycle-hooks/to-save-settings'; -import { Logger } from './logging/logger.service'; import { TaskManager } from './runners/task-managers/task-manager'; import { SecretsHelper } from './secrets-helpers'; import { OwnershipService } from './services/ownership.service'; diff --git a/packages/cli/src/workflow-runner.ts b/packages/cli/src/workflow-runner.ts index 973d512e62079..30cd50d6f0fd8 100644 --- a/packages/cli/src/workflow-runner.ts +++ b/packages/cli/src/workflow-runner.ts @@ -2,7 +2,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-shadow */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import { ErrorReporter, InstanceSettings, WorkflowExecute } from 'n8n-core'; +import { ErrorReporter, InstanceSettings, Logger, WorkflowExecute } from 'n8n-core'; import type { ExecutionError, IDeferredPromise, @@ -21,7 +21,6 @@ import { ActiveExecutions } from '@/active-executions'; import config from '@/config'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import type { ScalingService } from '@/scaling/scaling.service'; import type { Job, JobData } from '@/scaling/scaling.types'; diff --git a/packages/cli/src/workflows/workflow-execution.service.ts b/packages/cli/src/workflows/workflow-execution.service.ts index 27b673c245f66..842ddfe72661b 100644 --- a/packages/cli/src/workflows/workflow-execution.service.ts +++ b/packages/cli/src/workflows/workflow-execution.service.ts @@ -1,5 +1,5 @@ import { GlobalConfig } from '@n8n/config'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import type { IDeferredPromise, IExecuteData, @@ -20,7 +20,6 @@ import type { User } from '@/databases/entities/user'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import type { CreateExecutionPayload, IWorkflowDb, IWorkflowErrorData } from '@/interfaces'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { SubworkflowPolicyChecker } from '@/subworkflows/subworkflow-policy-checker.service'; import { TestWebhooks } from '@/webhooks/test-webhooks'; diff --git a/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts b/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts index 3b171e34227c4..2e23a7d64a3e0 100644 --- a/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts +++ b/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts @@ -1,3 +1,4 @@ +import { Logger } from 'n8n-core'; import { ensureError } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -8,7 +9,6 @@ import { SharedWorkflowRepository } from '@/databases/repositories/shared-workfl import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; import { SharedWorkflowNotFoundError } from '@/errors/shared-workflow-not-found.error'; import { WorkflowHistoryVersionNotFoundError } from '@/errors/workflow-history-version-not-found.error'; -import { Logger } from '@/logging/logger.service'; import { isWorkflowHistoryEnabled } from './workflow-history-helper.ee'; diff --git a/packages/cli/src/workflows/workflow-static-data.service.ts b/packages/cli/src/workflows/workflow-static-data.service.ts index 3e5159dc9a438..aaff18f319262 100644 --- a/packages/cli/src/workflows/workflow-static-data.service.ts +++ b/packages/cli/src/workflows/workflow-static-data.service.ts @@ -1,10 +1,9 @@ import { GlobalConfig } from '@n8n/config'; -import { ErrorReporter } from 'n8n-core'; +import { ErrorReporter, Logger } from 'n8n-core'; import type { IDataObject, Workflow } from 'n8n-workflow'; import { Service } from 'typedi'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { Logger } from '@/logging/logger.service'; import { isWorkflowIdValid } from '@/utils'; @Service() diff --git a/packages/cli/src/workflows/workflow.service.ee.ts b/packages/cli/src/workflows/workflow.service.ee.ts index 90a8af90b1678..debaf85073c43 100644 --- a/packages/cli/src/workflows/workflow.service.ee.ts +++ b/packages/cli/src/workflows/workflow.service.ee.ts @@ -1,6 +1,7 @@ // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In, type EntityManager } from '@n8n/typeorm'; import omit from 'lodash/omit'; +import { Logger } from 'n8n-core'; import { ApplicationError, NodeOperationError, WorkflowActivationError } from 'n8n-workflow'; import { Service } from 'typedi'; @@ -17,7 +18,6 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { TransferWorkflowError } from '@/errors/response-errors/transfer-workflow.error'; -import { Logger } from '@/logging/logger.service'; import { OwnershipService } from '@/services/ownership.service'; import { ProjectService } from '@/services/project.service'; diff --git a/packages/cli/src/workflows/workflow.service.ts b/packages/cli/src/workflows/workflow.service.ts index 7220e1a640cad..facd372656d9e 100644 --- a/packages/cli/src/workflows/workflow.service.ts +++ b/packages/cli/src/workflows/workflow.service.ts @@ -5,7 +5,7 @@ import type { EntityManager } from '@n8n/typeorm'; import { In } from '@n8n/typeorm'; import omit from 'lodash/omit'; import pick from 'lodash/pick'; -import { BinaryDataService } from 'n8n-core'; +import { BinaryDataService, Logger } from 'n8n-core'; import { NodeApiError } from 'n8n-workflow'; import { Service } from 'typedi'; import { v4 as uuid } from 'uuid'; @@ -24,7 +24,6 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; -import { Logger } from '@/logging/logger.service'; import { hasSharing, type ListQuery } from '@/requests'; import { OrchestrationService } from '@/services/orchestration.service'; import { OwnershipService } from '@/services/ownership.service'; diff --git a/packages/cli/src/workflows/workflows.controller.ts b/packages/cli/src/workflows/workflows.controller.ts index 24765b422a2c1..f097b3cab61f9 100644 --- a/packages/cli/src/workflows/workflows.controller.ts +++ b/packages/cli/src/workflows/workflows.controller.ts @@ -3,6 +3,7 @@ import { GlobalConfig } from '@n8n/config'; import { In, type FindOptionsRelations } from '@n8n/typeorm'; import axios from 'axios'; import express from 'express'; +import { Logger } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; import { v4 as uuid } from 'uuid'; import { z } from 'zod'; @@ -27,7 +28,6 @@ import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; import type { IWorkflowResponse } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { listQueryMiddleware } from '@/middlewares'; import * as ResponseHelper from '@/response-helper'; import { NamingService } from '@/services/naming.service'; diff --git a/packages/cli/test/integration/active-workflow-manager.test.ts b/packages/cli/test/integration/active-workflow-manager.test.ts index a3e4f657f26ed..f724d156a8277 100644 --- a/packages/cli/test/integration/active-workflow-manager.test.ts +++ b/packages/cli/test/integration/active-workflow-manager.test.ts @@ -1,4 +1,5 @@ import { mock } from 'jest-mock-extended'; +import { Logger } from 'n8n-core'; import { NodeApiError, Workflow } from 'n8n-workflow'; import type { IWebhookData, WorkflowActivateMode } from 'n8n-workflow'; import { Container } from 'typedi'; @@ -9,7 +10,6 @@ import type { WebhookEntity } from '@/databases/entities/webhook-entity'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { ExecutionService } from '@/executions/execution.service'; import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { Push } from '@/push'; import { SecretsHelper } from '@/secrets-helpers'; diff --git a/packages/cli/test/integration/pruning.service.test.ts b/packages/cli/test/integration/pruning.service.test.ts index 4f34048a1a465..9d4103e84e802 100644 --- a/packages/cli/test/integration/pruning.service.test.ts +++ b/packages/cli/test/integration/pruning.service.test.ts @@ -21,7 +21,7 @@ import { mockInstance, mockLogger } from '../shared/mocking'; describe('softDeleteOnPruningCycle()', () => { let pruningService: PruningService; - const instanceSettings = new InstanceSettings(mock()); + const instanceSettings = Container.get(InstanceSettings); instanceSettings.markAsLeader(); const now = new Date(); diff --git a/packages/cli/test/integration/shared/db/workflows.ts b/packages/cli/test/integration/shared/db/workflows.ts index 5c86f1dc3534b..bc8099e494fed 100644 --- a/packages/cli/test/integration/shared/db/workflows.ts +++ b/packages/cli/test/integration/shared/db/workflows.ts @@ -40,6 +40,7 @@ export function newWorkflow(attributes: Partial = {}): WorkflowE ], connections: connections ?? {}, versionId: versionId ?? uuid(), + settings: {}, ...attributes, }); diff --git a/packages/cli/test/integration/shared/utils/test-server.ts b/packages/cli/test/integration/shared/utils/test-server.ts index ef0588b8d731c..f99e0938546ff 100644 --- a/packages/cli/test/integration/shared/utils/test-server.ts +++ b/packages/cli/test/integration/shared/utils/test-server.ts @@ -1,5 +1,6 @@ import cookieParser from 'cookie-parser'; import express from 'express'; +import { Logger } from 'n8n-core'; import type superagent from 'superagent'; import request from 'supertest'; import { Container } from 'typedi'; @@ -11,7 +12,6 @@ import { AUTH_COOKIE_NAME } from '@/constants'; import type { User } from '@/databases/entities/user'; import { ControllerRegistry } from '@/decorators'; import { License } from '@/license'; -import { Logger } from '@/logging/logger.service'; import { rawBodyReader, bodyParser } from '@/middlewares'; import { PostHogClient } from '@/posthog'; import { Push } from '@/push'; diff --git a/packages/cli/test/shared/mocking.ts b/packages/cli/test/shared/mocking.ts index 129acb585c62a..535388c55626b 100644 --- a/packages/cli/test/shared/mocking.ts +++ b/packages/cli/test/shared/mocking.ts @@ -1,11 +1,10 @@ import { DataSource, EntityManager, type EntityMetadata } from '@n8n/typeorm'; import { mock } from 'jest-mock-extended'; import type { Class } from 'n8n-core'; +import type { Logger } from 'n8n-core'; import type { DeepPartial } from 'ts-essentials'; import { Container } from 'typedi'; -import type { Logger } from '@/logging/logger.service'; - export const mockInstance = ( serviceClass: Class, data: DeepPartial | undefined = undefined, diff --git a/packages/core/package.json b/packages/core/package.json index 26b41800d9c75..401a9f81c749f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -42,6 +42,7 @@ "@sentry/node": "catalog:", "aws4": "1.11.0", "axios": "catalog:", + "callsites": "catalog:", "chardet": "2.0.0", "concat-stream": "2.0.0", "cron": "3.1.7", @@ -56,11 +57,13 @@ "nanoid": "catalog:", "oauth-1.0a": "2.2.6", "p-cancelable": "2.1.1", + "picocolors": "catalog:", "pretty-bytes": "5.6.0", "qs": "6.11.0", "ssh2": "1.15.0", "typedi": "catalog:", "uuid": "catalog:", + "winston": "3.14.2", "xml2js": "catalog:", "zod": "catalog:" } diff --git a/packages/core/src/ActiveWorkflows.ts b/packages/core/src/ActiveWorkflows.ts index e3ca8614c2fa8..173f73baca939 100644 --- a/packages/core/src/ActiveWorkflows.ts +++ b/packages/core/src/ActiveWorkflows.ts @@ -11,7 +11,6 @@ import type { } from 'n8n-workflow'; import { ApplicationError, - LoggerProxy as Logger, toCronExpression, TriggerCloseError, WorkflowActivationError, @@ -21,12 +20,14 @@ import { Service } from 'typedi'; import { ErrorReporter } from './error-reporter'; import type { IWorkflowData } from './Interfaces'; +import { Logger } from './logging/logger'; import { ScheduledTaskManager } from './ScheduledTaskManager'; import { TriggersAndPollers } from './TriggersAndPollers'; @Service() export class ActiveWorkflows { constructor( + private readonly logger: Logger, private readonly scheduledTaskManager: ScheduledTaskManager, private readonly triggersAndPollers: TriggersAndPollers, private readonly errorReporter: ErrorReporter, @@ -151,7 +152,7 @@ export class ActiveWorkflows { const cronTimes = (pollTimes.item || []).map(toCronExpression); // The trigger function to execute when the cron-time got reached const executeTrigger = async (testingTrigger = false) => { - Logger.debug(`Polling trigger initiated for workflow "${workflow.name}"`, { + this.logger.debug(`Polling trigger initiated for workflow "${workflow.name}"`, { workflowName: workflow.name, workflowId: workflow.id, }); @@ -193,7 +194,7 @@ export class ActiveWorkflows { */ async remove(workflowId: string) { if (!this.isActive(workflowId)) { - Logger.warn(`Cannot deactivate already inactive workflow ID "${workflowId}"`); + this.logger.warn(`Cannot deactivate already inactive workflow ID "${workflowId}"`); return false; } @@ -222,7 +223,7 @@ export class ActiveWorkflows { await response.closeFunction(); } catch (e) { if (e instanceof TriggerCloseError) { - Logger.error( + this.logger.error( `There was a problem calling "closeFunction" on "${e.node.name}" in workflow "${workflowId}"`, ); this.errorReporter.error(e, { extra: { workflowId } }); diff --git a/packages/core/src/Constants.ts b/packages/core/src/Constants.ts index ceaf77566a0d3..82a39b07cd26d 100644 --- a/packages/core/src/Constants.ts +++ b/packages/core/src/Constants.ts @@ -1,6 +1,10 @@ import type { INodeProperties } from 'n8n-workflow'; import { cronNodeOptions } from 'n8n-workflow'; +const { NODE_ENV } = process.env; +export const inProduction = NODE_ENV === 'production'; +export const inDevelopment = !NODE_ENV || NODE_ENV === 'development'; + export const CUSTOM_EXTENSION_ENV = 'N8N_CUSTOM_EXTENSIONS'; export const PLACEHOLDER_EMPTY_EXECUTION_ID = '__UNKNOWN__'; export const PLACEHOLDER_EMPTY_WORKFLOW_ID = '__EMPTY__'; diff --git a/packages/core/src/DirectoryLoader.ts b/packages/core/src/DirectoryLoader.ts index cd223da2ddf6f..fe9fee87694e4 100644 --- a/packages/core/src/DirectoryLoader.ts +++ b/packages/core/src/DirectoryLoader.ts @@ -15,15 +15,13 @@ import type { IVersionedNodeType, KnownNodesAndCredentials, } from 'n8n-workflow'; -import { - ApplicationError, - LoggerProxy as Logger, - applyDeclarativeNodeOptionParameters, - jsonParse, -} from 'n8n-workflow'; +import { ApplicationError, applyDeclarativeNodeOptionParameters, jsonParse } from 'n8n-workflow'; import { readFileSync } from 'node:fs'; import { readFile } from 'node:fs/promises'; import * as path from 'path'; +import Container from 'typedi'; + +import { Logger } from '@/logging/logger'; import { loadClassInIsolation } from './ClassLoader'; import { commonCORSParameters, commonPollingParameters, CUSTOM_NODES_CATEGORY } from './Constants'; @@ -78,6 +76,8 @@ export abstract class DirectoryLoader { readonly nodesByCredential: Record = {}; + protected readonly logger = Container.get(Logger); + constructor( readonly directory: string, protected readonly excludeNodes: string[] = [], @@ -336,7 +336,7 @@ export abstract class DirectoryLoader { node.description.codex = codex; } catch { - Logger.debug(`No codex available for: ${node.description.name}`); + this.logger.debug(`No codex available for: ${node.description.name}`); if (isCustom) { node.description.codex = { @@ -454,7 +454,7 @@ export class PackageDirectoryLoader extends DirectoryLoader { this.inferSupportedNodes(); - Logger.debug(`Loaded all credentials and nodes from ${this.packageName}`, { + this.logger.debug(`Loaded all credentials and nodes from ${this.packageName}`, { credentials: credentials?.length ?? 0, nodes: nodes?.length ?? 0, }); @@ -550,7 +550,7 @@ export class LazyPackageDirectoryLoader extends PackageDirectoryLoader { ); } - Logger.debug(`Lazy-loading nodes and credentials from ${this.packageJson.name}`, { + this.logger.debug(`Lazy-loading nodes and credentials from ${this.packageJson.name}`, { nodes: this.types.nodes?.length ?? 0, credentials: this.types.credentials?.length ?? 0, }); @@ -559,7 +559,7 @@ export class LazyPackageDirectoryLoader extends PackageDirectoryLoader { return; // We can load nodes and credentials lazily now } catch { - Logger.debug("Can't enable lazy-loading"); + this.logger.debug("Can't enable lazy-loading"); await super.loadAll(); } } diff --git a/packages/core/src/InstanceSettings.ts b/packages/core/src/InstanceSettings.ts index f611e034b337f..814f75ef94835 100644 --- a/packages/core/src/InstanceSettings.ts +++ b/packages/core/src/InstanceSettings.ts @@ -5,6 +5,8 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync import path from 'path'; import { Service } from 'typedi'; +import { Logger } from '@/logging/logger'; + import { Memoized } from './decorators'; import { InstanceSettingsConfig } from './InstanceSettingsConfig'; @@ -28,13 +30,11 @@ const inTest = process.env.NODE_ENV === 'test'; @Service() export class InstanceSettings { - private readonly userHome = this.getUserHome(); - /** The path to the n8n folder in which all n8n related data gets saved */ - readonly n8nFolder = path.join(this.userHome, '.n8n'); + readonly n8nFolder = this.config.n8nFolder; /** The path to the folder where all generated static assets are copied to */ - readonly staticCacheDir = path.join(this.userHome, '.cache/n8n/public'); + readonly staticCacheDir = path.join(this.config.userHome, '.cache/n8n/public'); /** The path to the folder containing custom nodes and credentials */ readonly customExtensionDir = path.join(this.n8nFolder, 'custom'); @@ -58,7 +58,10 @@ export class InstanceSettings { readonly instanceType: InstanceType; - constructor(private readonly config: InstanceSettingsConfig) { + constructor( + private readonly config: InstanceSettingsConfig, + private readonly logger: Logger, + ) { const command = process.argv[2]; this.instanceType = ['webhook', 'worker'].includes(command) ? (command as InstanceType) @@ -154,15 +157,6 @@ export class InstanceSettings { this.save({ ...this.settings, ...newSettings }); } - /** - * The home folder path of the user. - * If none can be found it falls back to the current working directory - */ - private getUserHome() { - const homeVarName = process.platform === 'win32' ? 'USERPROFILE' : 'HOME'; - return process.env.N8N_USER_FOLDER ?? process.env[homeVarName] ?? process.cwd(); - } - /** * Load instance settings from the settings file. If missing, create a new * settings file with an auto-generated encryption key. @@ -198,7 +192,9 @@ export class InstanceSettings { this.save(settings); if (!inTest && !process.env.N8N_ENCRYPTION_KEY) { - console.info(`No encryption key found - Auto-generated and saved to: ${this.settingsFile}`); + this.logger.info( + `No encryption key found - Auto-generated and saved to: ${this.settingsFile}`, + ); } this.ensureSettingsFilePermissions(); @@ -260,11 +256,11 @@ export class InstanceSettings { const permissionsResult = toResult(() => { const stats = statSync(this.settingsFile); - return stats.mode & 0o777; + return stats?.mode & 0o777; }); // If we can't determine the permissions, log a warning and skip the check if (!permissionsResult.ok) { - console.warn( + this.logger.warn( `Could not ensure settings file permissions: ${permissionsResult.error.message}. To skip this check, set N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false.`, ); return; @@ -277,7 +273,7 @@ export class InstanceSettings { // If the permissions are incorrect and the flag is not set, log a warning if (!this.enforceSettingsFilePermissions.isSet) { - console.warn( + this.logger.warn( `Permissions 0${permissionsResult.result.toString(8)} for n8n settings file ${this.settingsFile} are too wide. This is ignored for now, but in the future n8n will attempt to change the permissions automatically. To automatically enforce correct permissions now set N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true (recommended), or turn this check off set N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false.`, ); // The default is false so we skip the enforcement for now @@ -285,7 +281,7 @@ export class InstanceSettings { } if (this.enforceSettingsFilePermissions.enforce) { - console.warn( + this.logger.warn( `Permissions 0${permissionsResult.result.toString(8)} for n8n settings file ${this.settingsFile} are too wide. Changing permissions to 0600..`, ); const chmodResult = toResult(() => chmodSync(this.settingsFile, 0o600)); @@ -293,7 +289,7 @@ export class InstanceSettings { // Some filesystems don't support permissions. In this case we log the // error and ignore it. We might want to prevent the app startup in the // future in this case. - console.warn( + this.logger.warn( `Could not enforce settings file permissions: ${chmodResult.error.message}. To skip this check, set N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false.`, ); } diff --git a/packages/core/src/InstanceSettingsConfig.ts b/packages/core/src/InstanceSettingsConfig.ts index 60baf8b80f9cd..dd28472a05050 100644 --- a/packages/core/src/InstanceSettingsConfig.ts +++ b/packages/core/src/InstanceSettingsConfig.ts @@ -1,4 +1,5 @@ import { Config, Env } from '@n8n/config'; +import path from 'node:path'; @Config export class InstanceSettingsConfig { @@ -9,4 +10,19 @@ export class InstanceSettingsConfig { */ @Env('N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS') enforceSettingsFilePermissions: boolean = false; + + /** + * The home folder path of the user. + * If none can be found it falls back to the current working directory + */ + readonly userHome: string; + + readonly n8nFolder: string; + + constructor() { + const homeVarName = process.platform === 'win32' ? 'USERPROFILE' : 'HOME'; + this.userHome = process.env.N8N_USER_FOLDER ?? process.env[homeVarName] ?? process.cwd(); + + this.n8nFolder = path.join(this.userHome, '.n8n'); + } } diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 20d5ae0833f04..3a0ebf22f9309 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -76,7 +76,6 @@ import type { SchedulingFunctions, } from 'n8n-workflow'; import { - LoggerProxy as Logger, NodeApiError, NodeHelpers, NodeOperationError, @@ -97,6 +96,8 @@ import { Readable } from 'stream'; import Container from 'typedi'; import url, { URL, URLSearchParams } from 'url'; +import { Logger } from '@/logging/logger'; + import { BinaryDataService } from './BinaryData/BinaryData.service'; import type { BinaryData } from './BinaryData/types'; import { binaryToBuffer } from './BinaryData/utils'; @@ -201,7 +202,7 @@ async function generateContentLengthHeader(config: AxiosRequestConfig) { 'content-length': length, }; } catch (error) { - Logger.error('Unable to calculate form data length', { error }); + Container.get(Logger).error('Unable to calculate form data length', { error }); } } @@ -792,7 +793,7 @@ export async function proxyRequestToAxios( error.config = error.request = undefined; error.options = pick(config ?? {}, ['url', 'method', 'data', 'headers']); if (response) { - Logger.debug('Request proxied to Axios failed', { status: response.status }); + Container.get(Logger).debug('Request proxied to Axios failed', { status: response.status }); let responseData = response.data; if (Buffer.isBuffer(responseData) || responseData instanceof Readable) { @@ -1406,7 +1407,7 @@ export async function requestOAuth2( if (isN8nRequest) { return await this.helpers.httpRequest(newRequestOptions).catch(async (error: AxiosError) => { if (error.response?.status === 401) { - Logger.debug( + this.logger.debug( `OAuth2 token for "${credentialsType}" used by node "${node.name}" expired. Should revalidate.`, ); const tokenRefreshOptions: IDataObject = {}; @@ -1425,7 +1426,7 @@ export async function requestOAuth2( let newToken; - Logger.debug( + this.logger.debug( `OAuth2 token for "${credentialsType}" used by node "${node.name}" has been renewed.`, ); // if it's OAuth2 with client credentials grant type, get a new token @@ -1436,7 +1437,7 @@ export async function requestOAuth2( newToken = await token.refresh(tokenRefreshOptions as unknown as ClientOAuth2Options); } - Logger.debug( + this.logger.debug( `OAuth2 token for "${credentialsType}" used by node "${node.name}" has been renewed.`, ); @@ -1499,7 +1500,7 @@ export async function requestOAuth2( Authorization: '', }; } - Logger.debug( + this.logger.debug( `OAuth2 token for "${credentialsType}" used by node "${node.name}" expired. Should revalidate.`, ); @@ -1512,7 +1513,7 @@ export async function requestOAuth2( } else { newToken = await token.refresh(tokenRefreshOptions as unknown as ClientOAuth2Options); } - Logger.debug( + this.logger.debug( `OAuth2 token for "${credentialsType}" used by node "${node.name}" has been renewed.`, ); @@ -1534,7 +1535,7 @@ export async function requestOAuth2( credentials as unknown as ICredentialDataDecryptedObject, ); - Logger.debug( + this.logger.debug( `OAuth2 token for "${credentialsType}" used by node "${node.name}" has been saved to database successfully.`, ); @@ -2562,6 +2563,7 @@ export function getExecuteTriggerFunctions( export function getCredentialTestFunctions(): ICredentialTestFunctions { return { + logger: Container.get(Logger), helpers: { ...getSSHTunnelFunctions(), request: async (uriOrObject: string | object, options?: object) => { diff --git a/packages/core/src/ObjectStore/ObjectStore.service.ee.ts b/packages/core/src/ObjectStore/ObjectStore.service.ee.ts index 0e4d8463dfccb..6379de7789f88 100644 --- a/packages/core/src/ObjectStore/ObjectStore.service.ee.ts +++ b/packages/core/src/ObjectStore/ObjectStore.service.ee.ts @@ -2,11 +2,13 @@ import { sign } from 'aws4'; import type { Request as Aws4Options, Credentials as Aws4Credentials } from 'aws4'; import axios from 'axios'; import type { AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig, Method } from 'axios'; -import { ApplicationError, LoggerProxy as Logger } from 'n8n-workflow'; +import { ApplicationError } from 'n8n-workflow'; import { createHash } from 'node:crypto'; import type { Readable } from 'stream'; import { Service } from 'typedi'; +import { Logger } from '@/logging/logger'; + import type { Bucket, ConfigSchemaCredentials, @@ -30,7 +32,7 @@ export class ObjectStoreService { private isReadOnly = false; - private logger = Logger; + constructor(private readonly logger: Logger) {} async init(host: string, bucket: Bucket, credentials: ConfigSchemaCredentials) { this.host = host; diff --git a/packages/core/src/SerializedBuffer.ts b/packages/core/src/SerializedBuffer.ts index 7a96884729bcf..d6ea874c7a61d 100644 --- a/packages/core/src/SerializedBuffer.ts +++ b/packages/core/src/SerializedBuffer.ts @@ -1,4 +1,4 @@ -import { isObjectLiteral } from './utils'; +import { isObjectLiteral } from '@/utils'; /** A nodejs Buffer gone through JSON.stringify */ export type SerializedBuffer = { diff --git a/packages/core/src/__tests__/ActiveWorkflows.test.ts b/packages/core/src/__tests__/ActiveWorkflows.test.ts index 85487a0cece09..410b4779bae94 100644 --- a/packages/core/src/__tests__/ActiveWorkflows.test.ts +++ b/packages/core/src/__tests__/ActiveWorkflows.test.ts @@ -42,7 +42,12 @@ describe('ActiveWorkflows', () => { beforeEach(() => { jest.clearAllMocks(); - activeWorkflows = new ActiveWorkflows(scheduledTaskManager, triggersAndPollers, errorReporter); + activeWorkflows = new ActiveWorkflows( + mock(), + scheduledTaskManager, + triggersAndPollers, + errorReporter, + ); }); type PollTimes = { item: TriggerTime[] }; diff --git a/packages/core/src/error-reporter.ts b/packages/core/src/error-reporter.ts index b6fc936daaa7a..b52fd6d2f6279 100644 --- a/packages/core/src/error-reporter.ts +++ b/packages/core/src/error-reporter.ts @@ -2,11 +2,12 @@ import type { NodeOptions } from '@sentry/node'; import { close } from '@sentry/node'; import type { ErrorEvent, EventHint } from '@sentry/types'; import { AxiosError } from 'axios'; -import { ApplicationError, LoggerProxy, type ReportingOptions } from 'n8n-workflow'; +import { ApplicationError, type ReportingOptions } from 'n8n-workflow'; import { createHash } from 'node:crypto'; import { Service } from 'typedi'; import type { InstanceType } from './InstanceSettings'; +import { Logger } from './logging/logger'; @Service() export class ErrorReporter { @@ -15,7 +16,7 @@ export class ErrorReporter { private report: (error: Error | string, options?: ReportingOptions) => void; - constructor() { + constructor(private readonly logger: Logger) { // eslint-disable-next-line @typescript-eslint/unbound-method this.report = this.defaultReport; } @@ -30,7 +31,7 @@ export class ErrorReporter { do { const msg = [e.message + context, e.stack ? `\n${e.stack}\n` : ''].join(''); const meta = e instanceof ApplicationError ? e.extra : undefined; - LoggerProxy.error(msg, meta); + this.logger.error(msg, meta); e = e.cause as Error; } while (e); } diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index bec9767ffa923..7abbd9ad9aa7f 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -11,6 +11,7 @@ export * from './Credentials'; export * from './DirectoryLoader'; export * from './Interfaces'; export { InstanceSettings, InstanceType } from './InstanceSettings'; +export { Logger } from './logging/logger'; export * from './NodeExecuteFunctions'; export * from './RoutingNode'; export * from './WorkflowExecute'; diff --git a/packages/cli/src/logging/__tests__/logger.service.test.ts b/packages/core/src/logging/__tests__/logger.test.ts similarity index 93% rename from packages/cli/src/logging/__tests__/logger.service.test.ts rename to packages/core/src/logging/__tests__/logger.test.ts index 2ffbf2120eb34..d34eaf250a099 100644 --- a/packages/cli/src/logging/__tests__/logger.service.test.ts +++ b/packages/core/src/logging/__tests__/logger.test.ts @@ -5,10 +5,11 @@ jest.mock('n8n-workflow', () => ({ import type { GlobalConfig } from '@n8n/config'; import { mock } from 'jest-mock-extended'; -import type { InstanceSettings } from 'n8n-core'; import { LoggerProxy } from 'n8n-workflow'; -import { Logger } from '@/logging/logger.service'; +import type { InstanceSettingsConfig } from '@/InstanceSettingsConfig'; + +import { Logger } from '../logger'; describe('Logger', () => { beforeEach(() => { @@ -25,13 +26,13 @@ describe('Logger', () => { }); test('if root, should initialize `LoggerProxy` with instance', () => { - const logger = new Logger(globalConfig, mock(), { isRoot: true }); + const logger = new Logger(globalConfig, mock(), { isRoot: true }); expect(LoggerProxy.init).toHaveBeenCalledWith(logger); }); test('if scoped, should not initialize `LoggerProxy`', () => { - new Logger(globalConfig, mock(), { isRoot: false }); + new Logger(globalConfig, mock(), { isRoot: false }); expect(LoggerProxy.init).not.toHaveBeenCalled(); }); @@ -47,7 +48,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock()); + const logger = new Logger(globalConfig, mock()); const { transports } = logger.getInternalLogger(); @@ -72,7 +73,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock({ n8nFolder: '/tmp' })); + const logger = new Logger(globalConfig, mock({ n8nFolder: '/tmp' })); const { transports } = logger.getInternalLogger(); @@ -94,7 +95,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock()); + const logger = new Logger(globalConfig, mock()); const internalLogger = logger.getInternalLogger(); @@ -113,7 +114,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock()); + const logger = new Logger(globalConfig, mock()); const internalLogger = logger.getInternalLogger(); @@ -132,7 +133,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock()); + const logger = new Logger(globalConfig, mock()); const internalLogger = logger.getInternalLogger(); @@ -151,7 +152,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock()); + const logger = new Logger(globalConfig, mock()); const internalLogger = logger.getInternalLogger(); @@ -170,7 +171,7 @@ describe('Logger', () => { }, }); - const logger = new Logger(globalConfig, mock()); + const logger = new Logger(globalConfig, mock()); const internalLogger = logger.getInternalLogger(); diff --git a/packages/cli/src/logging/logger.service.ts b/packages/core/src/logging/logger.ts similarity index 89% rename from packages/cli/src/logging/logger.service.ts rename to packages/core/src/logging/logger.ts index 46441e5a339ca..e959affba3b16 100644 --- a/packages/cli/src/logging/logger.service.ts +++ b/packages/core/src/logging/logger.ts @@ -2,20 +2,26 @@ import type { LogScope } from '@n8n/config'; import { GlobalConfig } from '@n8n/config'; import callsites from 'callsites'; import type { TransformableInfo } from 'logform'; -import { InstanceSettings, isObjectLiteral } from 'n8n-core'; import { LoggerProxy, LOG_LEVELS } from 'n8n-workflow'; +import type { + Logger as LoggerType, + LogLocationMetadata, + LogLevel, + LogMetadata, +} from 'n8n-workflow'; import path, { basename } from 'node:path'; import pc from 'picocolors'; import { Service } from 'typedi'; import winston from 'winston'; -import { inDevelopment, inProduction } from '@/constants'; +import { inDevelopment, inProduction } from '@/Constants'; +import { InstanceSettingsConfig } from '@/InstanceSettingsConfig'; +import { isObjectLiteral } from '@/utils'; -import { noOp } from './constants'; -import type { LogLocationMetadata, LogLevel, LogMetadata } from './types'; +const noOp = () => {}; @Service() -export class Logger { +export class Logger implements LoggerType { private internalLogger: winston.Logger; private readonly level: LogLevel; @@ -28,7 +34,7 @@ export class Logger { constructor( private readonly globalConfig: GlobalConfig, - private readonly instanceSettings: InstanceSettings, + private readonly instanceSettingsConfig: InstanceSettingsConfig, { isRoot }: { isRoot?: boolean } = { isRoot: true }, ) { this.level = this.globalConfig.logging.level; @@ -49,6 +55,8 @@ export class Logger { if (outputs.includes('file')) this.setFileTransport(); this.scopes = new Set(scopes); + } else { + this.scopes = new Set(); } if (isRoot) LoggerProxy.init(this); @@ -61,7 +69,9 @@ export class Logger { /** Create a logger that injects the given scopes into its log metadata. */ scoped(scopes: LogScope | LogScope[]) { scopes = Array.isArray(scopes) ? scopes : [scopes]; - const scopedLogger = new Logger(this.globalConfig, this.instanceSettings, { isRoot: false }); + const scopedLogger = new Logger(this.globalConfig, this.instanceSettingsConfig, { + isRoot: false, + }); const childLogger = this.internalLogger.child({ scopes }); scopedLogger.setInternalLogger(childLogger); @@ -107,10 +117,10 @@ export class Logger { } private scopeFilter() { - return winston.format((info: TransformableInfo & { metadata: LogMetadata }) => { + return winston.format((info: TransformableInfo) => { if (!this.isScopingEnabled) return info; - const { scopes } = info.metadata; + const { scopes } = (info as unknown as { metadata: LogMetadata }).metadata; const shouldIncludeScope = scopes && scopes?.length > 0 && scopes.some((s) => this.scopes.has(s)); @@ -179,7 +189,7 @@ export class Logger { ); const filename = path.join( - this.instanceSettings.n8nFolder, + this.instanceSettingsConfig.n8nFolder, this.globalConfig.logging.file.location, ); diff --git a/packages/core/src/node-execution-context/node-execution-context.ts b/packages/core/src/node-execution-context/node-execution-context.ts index 8477fe7856992..d303b10ba1b69 100644 --- a/packages/core/src/node-execution-context/node-execution-context.ts +++ b/packages/core/src/node-execution-context/node-execution-context.ts @@ -23,7 +23,6 @@ import { ApplicationError, deepCopy, ExpressionError, - LoggerProxy, NodeHelpers, NodeOperationError, } from 'n8n-workflow'; @@ -33,6 +32,7 @@ import { HTTP_REQUEST_NODE_TYPE, HTTP_REQUEST_TOOL_NODE_TYPE } from '@/Constants import { Memoized } from '@/decorators'; import { extractValue } from '@/ExtractValue'; import { InstanceSettings } from '@/InstanceSettings'; +import { Logger } from '@/logging/logger'; import { cleanupParameterData } from './utils/cleanupParameterData'; import { ensureType } from './utils/ensureType'; @@ -53,8 +53,9 @@ export abstract class NodeExecutionContext implements Omit { const userFolder = '/test'; @@ -11,12 +14,16 @@ describe('InstanceSettings', () => { const settingsFile = `${userFolder}/.n8n/config`; const mockFs = mock(fs); + const logger = mockInstance(Logger); const createInstanceSettings = (opts?: Partial) => - new InstanceSettings({ - ...new InstanceSettingsConfig(), - ...opts, - }); + new InstanceSettings( + { + ...new InstanceSettingsConfig(), + ...opts, + }, + logger, + ); beforeEach(() => { jest.resetAllMocks(); @@ -203,7 +210,7 @@ describe('InstanceSettings', () => { mockFs.readFileSync .calledWith(settingsFile) .mockReturnValue(JSON.stringify({ encryptionKey: 'test_key' })); - settings = new InstanceSettings(mock()); + settings = createInstanceSettings(); }); it('should return true if /.dockerenv exists', () => { diff --git a/packages/core/test/ObjectStore.service.test.ts b/packages/core/test/ObjectStore.service.test.ts index 77936c20f0bb5..9899ad17fc3cc 100644 --- a/packages/core/test/ObjectStore.service.test.ts +++ b/packages/core/test/ObjectStore.service.test.ts @@ -1,4 +1,5 @@ import axios from 'axios'; +import { mock } from 'jest-mock-extended'; import { Readable } from 'stream'; import { ObjectStoreService } from '@/ObjectStore/ObjectStore.service.ee'; @@ -25,7 +26,7 @@ const toDeletionXml = (filename: string) => ` let objectStoreService: ObjectStoreService; beforeEach(async () => { - objectStoreService = new ObjectStoreService(); + objectStoreService = new ObjectStoreService(mock()); mockAxios.request.mockResolvedValueOnce({ status: 200 }); // for checkConnection await objectStoreService.init(mockHost, mockBucket, mockCredentials); jest.restoreAllMocks(); diff --git a/packages/core/test/error-reporter.test.ts b/packages/core/test/error-reporter.test.ts index 1f507ab5c0081..7cd94fdb4b085 100644 --- a/packages/core/test/error-reporter.test.ts +++ b/packages/core/test/error-reporter.test.ts @@ -1,6 +1,7 @@ import { QueryFailedError } from '@n8n/typeorm'; import type { ErrorEvent } from '@sentry/types'; import { AxiosError } from 'axios'; +import { mock } from 'jest-mock-extended'; import { ApplicationError } from 'n8n-workflow'; import { ErrorReporter } from '@/error-reporter'; @@ -15,7 +16,7 @@ jest.mock('@sentry/node', () => ({ jest.spyOn(process, 'on'); describe('ErrorReporter', () => { - const errorReporter = new ErrorReporter(); + const errorReporter = new ErrorReporter(mock()); const event = {} as ErrorEvent; describe('beforeSend', () => { diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 401bb177c4cc5..654ae1be613ea 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -15,6 +15,7 @@ "include": ["src/**/*.ts", "test/**/*.ts"], "references": [ { "path": "../workflow/tsconfig.build.json" }, + { "path": "../@n8n/config/tsconfig.build.json" }, { "path": "../@n8n/client-oauth2/tsconfig.build.json" } ] } diff --git a/packages/nodes-base/nodes/Ldap/Helpers.ts b/packages/nodes-base/nodes/Ldap/Helpers.ts index 5e4447fa8463e..0b56b1b23057a 100644 --- a/packages/nodes-base/nodes/Ldap/Helpers.ts +++ b/packages/nodes-base/nodes/Ldap/Helpers.ts @@ -1,7 +1,6 @@ import { Client } from 'ldapts'; import type { ClientOptions, Entry } from 'ldapts'; -import type { ICredentialDataDecryptedObject, IDataObject } from 'n8n-workflow'; -import { LoggerProxy as Logger } from 'n8n-workflow'; +import type { ICredentialDataDecryptedObject, IDataObject, Logger } from 'n8n-workflow'; export const BINARY_AD_ATTRIBUTES = ['objectGUID', 'objectSid']; const resolveEntryBinaryAttributes = (entry: Entry): Entry => { @@ -18,6 +17,7 @@ export const resolveBinaryAttributes = (entries: Entry[]): void => { }; export async function createLdapClient( + context: { logger: Logger }, credentials: ICredentialDataDecryptedObject, nodeDebug?: boolean, nodeType?: string, @@ -45,7 +45,7 @@ export async function createLdapClient( } if (nodeDebug) { - Logger.info( + context.logger.info( `[${nodeType} | ${nodeName}] - LDAP Options: ${JSON.stringify(ldapOptions, null, 2)}`, ); } diff --git a/packages/nodes-base/nodes/Ldap/Ldap.node.ts b/packages/nodes-base/nodes/Ldap/Ldap.node.ts index 2d13e10314d0b..6c24606a67fbd 100644 --- a/packages/nodes-base/nodes/Ldap/Ldap.node.ts +++ b/packages/nodes-base/nodes/Ldap/Ldap.node.ts @@ -103,7 +103,7 @@ export class Ldap implements INodeType { credential: ICredentialsDecrypted, ): Promise { const credentials = credential.data as ICredentialDataDecryptedObject; - const client = await createLdapClient(credentials); + const client = await createLdapClient(this, credentials); try { await client.bind(credentials.bindDN as string, credentials.bindPassword as string); } catch (error) { @@ -123,7 +123,7 @@ export class Ldap implements INodeType { loadOptions: { async getAttributes(this: ILoadOptionsFunctions) { const credentials = await this.getCredentials('ldap'); - const client = await createLdapClient(credentials); + const client = await createLdapClient(this, credentials); try { await client.bind(credentials.bindDN as string, credentials.bindPassword as string); @@ -153,7 +153,7 @@ export class Ldap implements INodeType { async getObjectClasses(this: ILoadOptionsFunctions) { const credentials = await this.getCredentials('ldap'); - const client = await createLdapClient(credentials); + const client = await createLdapClient(this, credentials); try { await client.bind(credentials.bindDN as string, credentials.bindPassword as string); } catch (error) { @@ -196,7 +196,7 @@ export class Ldap implements INodeType { async getAttributesForDn(this: ILoadOptionsFunctions) { const credentials = await this.getCredentials('ldap'); - const client = await createLdapClient(credentials); + const client = await createLdapClient(this, credentials); try { await client.bind(credentials.bindDN as string, credentials.bindPassword as string); @@ -242,6 +242,7 @@ export class Ldap implements INodeType { const credentials = await this.getCredentials('ldap'); const client = await createLdapClient( + this, credentials, nodeDebug, this.getNode().type, diff --git a/packages/workflow/package.json b/packages/workflow/package.json index cabbeaaaaa618..3165343bd0a1d 100644 --- a/packages/workflow/package.json +++ b/packages/workflow/package.json @@ -31,6 +31,7 @@ ], "devDependencies": { "@langchain/core": "catalog:", + "@n8n/config": "workspace:*", "@types/deep-equal": "^1.0.1", "@types/express": "catalog:", "@types/jmespath": "^0.15.0", @@ -44,7 +45,7 @@ "@n8n_io/riot-tmpl": "4.0.0", "ast-types": "0.15.2", "axios": "catalog:", - "callsites": "3.1.0", + "callsites": "catalog:", "deep-equal": "2.2.0", "esprima-next": "5.8.4", "form-data": "catalog:", diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index 6c28d4664dc2c..a67f7b59b498a 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ - import type { CallbackManager as CallbackManagerLC } from '@langchain/core/callbacks/manager'; +import type { LogScope } from '@n8n/config'; import type { AxiosProxyConfig, GenericAbortSignal } from 'axios'; import type * as express from 'express'; import type FormData from 'form-data'; @@ -675,6 +675,7 @@ export type ICredentialTestFunction = ( ) => Promise; export interface ICredentialTestFunctions { + logger: Logger; helpers: SSHTunnelFunctions & { request: (uriOrObject: string | object, options?: object) => Promise; }; @@ -2447,7 +2448,17 @@ export interface WorkflowTestData { } export type LogLevel = (typeof LOG_LEVELS)[number]; -export type Logger = Record, (message: string, meta?: object) => void>; +export type LogMetadata = { + [key: string]: unknown; + scopes?: LogScope[]; + file?: string; + function?: string; +}; +export type Logger = Record< + Exclude, + (message: string, metadata?: LogMetadata) => void +>; +export type LogLocationMetadata = Pick; export interface IStatusCodeMessages { [key: string]: string; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a42e5578268d6..bf87db10a9c4a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,6 +33,9 @@ catalogs: basic-auth: specifier: 2.0.1 version: 2.0.1 + callsites: + specifier: 3.1.0 + version: 3.1.0 fast-glob: specifier: 3.2.12 version: 3.2.12 @@ -54,6 +57,9 @@ catalogs: nanoid: specifier: 3.3.8 version: 3.3.8 + picocolors: + specifier: 1.0.1 + version: 1.0.1 typedi: specifier: 0.10.0 version: 0.10.0 @@ -811,9 +817,6 @@ importers: cache-manager: specifier: 5.2.3 version: 5.2.3 - callsites: - specifier: 3.1.0 - version: 3.1.0 change-case: specifier: 4.1.2 version: 4.1.2 @@ -947,7 +950,7 @@ importers: specifier: 8.12.0 version: 8.12.0 picocolors: - specifier: 1.0.1 + specifier: 'catalog:' version: 1.0.1 pkce-challenge: specifier: 3.0.0 @@ -1006,9 +1009,6 @@ importers: validator: specifier: 13.7.0 version: 13.7.0 - winston: - specifier: 3.14.2 - version: 3.14.2 ws: specifier: '>=8.17.1' version: 8.17.1 @@ -1136,6 +1136,9 @@ importers: axios: specifier: 'catalog:' version: 1.7.4 + callsites: + specifier: 'catalog:' + version: 3.1.0 chardet: specifier: 2.0.0 version: 2.0.0 @@ -1178,6 +1181,9 @@ importers: p-cancelable: specifier: 2.1.1 version: 2.1.1 + picocolors: + specifier: 'catalog:' + version: 1.0.1 pretty-bytes: specifier: 5.6.0 version: 5.6.0 @@ -1193,6 +1199,9 @@ importers: uuid: specifier: 'catalog:' version: 10.0.0 + winston: + specifier: 3.14.2 + version: 3.14.2 xml2js: specifier: 'catalog:' version: 0.6.2 @@ -1934,7 +1943,7 @@ importers: specifier: 'catalog:' version: 1.7.4 callsites: - specifier: 3.1.0 + specifier: 'catalog:' version: 3.1.0 deep-equal: specifier: 2.2.0 @@ -1979,6 +1988,9 @@ importers: '@langchain/core': specifier: 'catalog:' version: 0.3.19(openai@4.73.1(encoding@0.1.13)(zod@3.23.8)) + '@n8n/config': + specifier: workspace:* + version: link:../@n8n/config '@types/deep-equal': specifier: ^1.0.1 version: 1.0.1 @@ -14448,13 +14460,13 @@ snapshots: '@babel/code-frame@7.24.6': dependencies: '@babel/highlight': 7.24.6 - picocolors: 1.0.1 + picocolors: 1.1.1 '@babel/code-frame@7.26.2': dependencies: '@babel/helper-validator-identifier': 7.25.9 js-tokens: 4.0.0 - picocolors: 1.0.1 + picocolors: 1.1.1 '@babel/compat-data@7.23.5': {} @@ -14701,7 +14713,7 @@ snapshots: '@babel/helper-validator-identifier': 7.24.7 chalk: 2.4.2 js-tokens: 4.0.0 - picocolors: 1.0.1 + picocolors: 1.1.1 '@babel/parser@7.25.6': dependencies: @@ -19415,7 +19427,7 @@ snapshots: caniuse-lite: 1.0.30001667 fraction.js: 4.3.7 normalize-range: 0.1.2 - picocolors: 1.0.1 + picocolors: 1.1.1 postcss: 8.4.38 postcss-value-parser: 4.2.0 @@ -19603,7 +19615,7 @@ snapshots: '@types/readable-stream': 4.0.10 buffer: 6.0.3 inherits: 2.0.4 - readable-stream: 4.4.2 + readable-stream: 4.5.2 blob-util@2.0.2: {} @@ -25032,13 +25044,13 @@ snapshots: postcss@8.4.31: dependencies: nanoid: 3.3.8 - picocolors: 1.0.1 + picocolors: 1.1.1 source-map-js: 1.2.1 postcss@8.4.38: dependencies: nanoid: 3.3.8 - picocolors: 1.0.1 + picocolors: 1.1.1 source-map-js: 1.2.0 postcss@8.4.49: @@ -26496,7 +26508,7 @@ snapshots: css-tree: 2.3.1 css-what: 6.1.0 csso: 5.0.5 - picocolors: 1.0.1 + picocolors: 1.1.1 swagger-ui-dist@5.11.0: {} @@ -26542,7 +26554,7 @@ snapshots: micromatch: 4.0.8 normalize-path: 3.0.0 object-hash: 3.0.0 - picocolors: 1.0.1 + picocolors: 1.1.1 postcss: 8.4.38 postcss-import: 15.1.0(postcss@8.4.38) postcss-js: 4.0.1(postcss@8.4.38) @@ -27094,7 +27106,7 @@ snapshots: dependencies: browserslist: 4.23.0 escalade: 3.1.1 - picocolors: 1.0.1 + picocolors: 1.1.1 update-browserslist-db@1.1.1(browserslist@4.24.2): dependencies: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 6888cae7ae5f2..9700a3a45bbdc 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -13,6 +13,7 @@ catalog: '@types/xml2js': ^0.4.14 axios: 1.7.4 basic-auth: 2.0.1 + callsites: 3.1.0 chokidar: 4.0.1 fast-glob: 3.2.12 flatted: 3.2.7 @@ -21,6 +22,7 @@ catalog: lodash: 4.17.21 luxon: 3.4.4 nanoid: 3.3.8 + picocolors: 1.0.1 typedi: 0.10.0 uuid: 10.0.0 xml2js: 0.6.2