diff --git a/packages/@n8n/config/src/configs/logging.config.ts b/packages/@n8n/config/src/configs/logging.config.ts new file mode 100644 index 0000000000..2f68416df4 --- /dev/null +++ b/packages/@n8n/config/src/configs/logging.config.ts @@ -0,0 +1,47 @@ +import { Config, Env, Nested } from '../decorators'; +import { StringArray } from '../utils'; + +@Config +class FileLoggingConfig { + /** + * Max number of log files to keep, or max number of days to keep logs for. + * Once the limit is reached, the oldest log files will be rotated out. + * If using days, append a `d` suffix. Only for `file` log output. + * + * @example `N8N_LOG_FILE_COUNT_MAX=7` will keep at most 7 files. + * @example `N8N_LOG_FILE_COUNT_MAX=7d` will keep at most 7 days worth of files. + */ + @Env('N8N_LOG_FILE_COUNT_MAX') + fileCountMax: number = 100; + + /** Max size (in MiB) for each log file. Only for `file` log output. */ + @Env('N8N_LOG_FILE_SIZE_MAX') + fileSizeMax: number = 16; + + /** Location of the log files inside `~/.n8n`. Only for `file` log output. */ + @Env('N8N_LOG_FILE_LOCATION') + location: string = 'logs/n8n.log'; +} + +@Config +export class LoggingConfig { + /** + * Minimum level of logs to output. Logs with this or higher level will be output; + * logs with lower levels will not. Exception: `silent` disables all logging. + * + * @example `N8N_LOG_LEVEL=info` will output `error`, `warn` and `info` logs, but not `debug`. + */ + @Env('N8N_LOG_LEVEL') + level: 'error' | 'warn' | 'info' | 'debug' | 'silent' = 'info'; + + /** + * Where to output logs to. Options are: `console` or `file` or both in a comma separated list. + * + * @example `N8N_LOG_OUTPUT=console,file` will output to both console and file. + */ + @Env('N8N_LOG_OUTPUT') + outputs: StringArray<'console' | 'file'> = ['console']; + + @Nested + file: FileLoggingConfig; +} diff --git a/packages/@n8n/config/src/index.ts b/packages/@n8n/config/src/index.ts index 5098093db4..e4cdd93284 100644 --- a/packages/@n8n/config/src/index.ts +++ b/packages/@n8n/config/src/index.ts @@ -5,6 +5,7 @@ import { EndpointsConfig } from './configs/endpoints.config'; import { EventBusConfig } from './configs/event-bus.config'; import { ExternalSecretsConfig } from './configs/external-secrets.config'; import { ExternalStorageConfig } from './configs/external-storage.config'; +import { LoggingConfig } from './configs/logging.config'; import { NodesConfig } from './configs/nodes.config'; import { PublicApiConfig } from './configs/public-api.config'; import { ScalingModeConfig } from './configs/scaling-mode.config'; @@ -81,4 +82,7 @@ export class GlobalConfig { @Nested queue: ScalingModeConfig; + + @Nested + logging: LoggingConfig; } diff --git a/packages/@n8n/config/src/utils.ts b/packages/@n8n/config/src/utils.ts new file mode 100644 index 0000000000..c90fcb8266 --- /dev/null +++ b/packages/@n8n/config/src/utils.ts @@ -0,0 +1,7 @@ +export class StringArray extends Array { + constructor(str: string) { + super(); + const parsed = str.split(',') as StringArray; + return parsed.every((i) => typeof i === 'string') ? parsed : []; + } +} diff --git a/packages/@n8n/config/test/config.test.ts b/packages/@n8n/config/test/config.test.ts index 11fd97a5db..a2fd191eab 100644 --- a/packages/@n8n/config/test/config.test.ts +++ b/packages/@n8n/config/test/config.test.ts @@ -225,6 +225,15 @@ describe('GlobalConfig', () => { backendDsn: '', frontendDsn: '', }, + logging: { + level: 'info', + outputs: ['console'], + file: { + fileCountMax: 100, + fileSizeMax: 16, + location: 'logs/n8n.log', + }, + }, }; it('should use all default values when no env variables are defined', () => { diff --git a/packages/cli/package.json b/packages/cli/package.json index 7b030b3eb9..1b33ba70a4 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -170,7 +170,7 @@ "typedi": "catalog:", "uuid": "catalog:", "validator": "13.7.0", - "winston": "3.8.2", + "winston": "3.14.2", "ws": "8.17.1", "xml2js": "catalog:", "xmllint-wasm": "3.0.1", diff --git a/packages/cli/src/__tests__/license.test.ts b/packages/cli/src/__tests__/license.test.ts index 6f2e06752f..35da918abb 100644 --- a/packages/cli/src/__tests__/license.test.ts +++ b/packages/cli/src/__tests__/license.test.ts @@ -5,7 +5,7 @@ import type { InstanceSettings } from 'n8n-core'; import config from '@/config'; import { N8N_VERSION } from '@/constants'; import { License } from '@/license'; -import type { Logger } from '@/logger'; +import type { Logger } from '@/logging/logger.service'; jest.mock('@n8n_io/license-sdk'); diff --git a/packages/cli/src/abstract-server.ts b/packages/cli/src/abstract-server.ts index 3c60a3e48d..95ecaccdc5 100644 --- a/packages/cli/src/abstract-server.ts +++ b/packages/cli/src/abstract-server.ts @@ -13,7 +13,7 @@ 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 '@/logger'; +import { Logger } from '@/logging/logger.service'; import { rawBodyReader, bodyParser, corsMiddleware } from '@/middlewares'; import { send, sendErrorResponse } from '@/response-helper'; import { WaitingForms } from '@/waiting-forms'; diff --git a/packages/cli/src/active-executions.ts b/packages/cli/src/active-executions.ts index 933bf9a944..f5835ca164 100644 --- a/packages/cli/src/active-executions.ts +++ b/packages/cli/src/active-executions.ts @@ -18,7 +18,7 @@ import type { IExecutionDb, IExecutionsCurrentSummary, } from '@/interfaces'; -import { Logger } from '@/logger'; +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 44172ef564..988a238887 100644 --- a/packages/cli/src/active-workflow-manager.ts +++ b/packages/cli/src/active-workflow-manager.ts @@ -37,6 +37,7 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository import { OnShutdown } from '@/decorators/on-shutdown'; import { ExternalHooks } from '@/external-hooks'; import type { IWorkflowDb } from '@/interfaces'; +import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import { ActiveWorkflowsService } from '@/services/active-workflows.service'; import { OrchestrationService } from '@/services/orchestration.service'; @@ -47,7 +48,6 @@ import { WorkflowExecutionService } from '@/workflows/workflow-execution.service import { WorkflowStaticDataService } from '@/workflows/workflow-static-data.service'; import { ExecutionService } from './executions/execution.service'; -import { Logger } from './logger'; interface QueuedActivation { activationMode: WorkflowActivateMode; diff --git a/packages/cli/src/auth/auth.service.ts b/packages/cli/src/auth/auth.service.ts index 481f25c897..989396df84 100644 --- a/packages/cli/src/auth/auth.service.ts +++ b/packages/cli/src/auth/auth.service.ts @@ -12,7 +12,7 @@ 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 '@/logger'; +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 109d6a91f5..7403dd337a 100644 --- a/packages/cli/src/commands/base-command.ts +++ b/packages/cli/src/commands/base-command.ts @@ -19,7 +19,7 @@ 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 '@/logger'; +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 9c7a37b533..463c9d617c 100644 --- a/packages/cli/src/commands/db/__tests__/revert.test.ts +++ b/packages/cli/src/commands/db/__tests__/revert.test.ts @@ -4,7 +4,7 @@ import { mock } from 'jest-mock-extended'; import { main } from '@/commands/db/revert'; import type { IrreversibleMigration, ReversibleMigration } from '@/databases/types'; -import { Logger } from '@/logger'; +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 dc3776a6af..7823506ee0 100644 --- a/packages/cli/src/commands/db/revert.ts +++ b/packages/cli/src/commands/db/revert.ts @@ -8,7 +8,7 @@ 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 '@/logger'; +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/start.ts b/packages/cli/src/commands/start.ts index 61212049d7..3c89c6b90e 100644 --- a/packages/cli/src/commands/start.ts +++ b/packages/cli/src/commands/start.ts @@ -365,10 +365,9 @@ export class Start extends BaseCommand { if (executions.length === 0) return; - this.logger.debug( - '[Startup] Found enqueued executions to run', - executions.map((e) => e.id), - ); + this.logger.debug('[Startup] Found enqueued executions to run', { + executionIds: executions.map((e) => e.id), + }); const ownershipService = Container.get(OwnershipService); const workflowRunner = Container.get(WorkflowRunner); diff --git a/packages/cli/src/concurrency/__tests__/concurrency-control.service.test.ts b/packages/cli/src/concurrency/__tests__/concurrency-control.service.test.ts index 75239f5e59..6774708099 100644 --- a/packages/cli/src/concurrency/__tests__/concurrency-control.service.test.ts +++ b/packages/cli/src/concurrency/__tests__/concurrency-control.service.test.ts @@ -11,7 +11,7 @@ import type { ExecutionRepository } from '@/databases/repositories/execution.rep import { InvalidConcurrencyLimitError } from '@/errors/invalid-concurrency-limit.error'; import type { EventService } from '@/events/event.service'; import type { IExecutingWorkflowData } from '@/interfaces'; -import type { Logger } from '@/logger'; +import type { Logger } from '@/logging/logger.service'; import type { Telemetry } from '@/telemetry'; import { ConcurrencyQueue } from '../concurrency-queue'; diff --git a/packages/cli/src/concurrency/concurrency-control.service.ts b/packages/cli/src/concurrency/concurrency-control.service.ts index db7826a258..1665279352 100644 --- a/packages/cli/src/concurrency/concurrency-control.service.ts +++ b/packages/cli/src/concurrency/concurrency-control.service.ts @@ -7,7 +7,8 @@ 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 '@/logger'; +import { Logger } from '@/logging/logger.service'; +import type { LogMetadata } from '@/logging/types'; import { Telemetry } from '@/telemetry'; import { ConcurrencyQueue } from './concurrency-queue'; @@ -170,8 +171,8 @@ export class ConcurrencyControlService { throw new UnknownExecutionModeError(mode); } - private log(message: string, meta?: object) { - this.logger.debug(['[Concurrency Control]', message].join(' '), meta); + private log(message: string, metadata?: LogMetadata) { + this.logger.debug(['[Concurrency Control]', message].join(' '), metadata); } private shouldReport(capacity: number) { diff --git a/packages/cli/src/config/schema.ts b/packages/cli/src/config/schema.ts index e811fe8e10..047df9341e 100644 --- a/packages/cli/src/config/schema.ts +++ b/packages/cli/src/config/schema.ts @@ -1,7 +1,6 @@ import { GlobalConfig } from '@n8n/config'; import convict from 'convict'; import { InstanceSettings } from 'n8n-core'; -import { LOG_LEVELS } from 'n8n-workflow'; import path from 'path'; import { Container } from 'typedi'; @@ -296,41 +295,6 @@ export const schema = { env: 'EXTERNAL_HOOK_FILES', }, - logs: { - level: { - doc: 'Log output level', - format: LOG_LEVELS, - default: 'info', - env: 'N8N_LOG_LEVEL', - }, - output: { - doc: 'Where to output logs. Options are: console, file. Multiple can be separated by comma (",")', - format: String, - default: 'console', - env: 'N8N_LOG_OUTPUT', - }, - file: { - fileCountMax: { - doc: 'Maximum number of files to keep.', - format: Number, - default: 100, - env: 'N8N_LOG_FILE_COUNT_MAX', - }, - fileSizeMax: { - doc: 'Maximum size for each log file in MB.', - format: Number, - default: 16, - env: 'N8N_LOG_FILE_SIZE_MAX', - }, - location: { - doc: 'Log file location; only used if log output is set to file.', - format: String, - default: path.join(Container.get(InstanceSettings).n8nFolder, 'logs/n8n.log'), - env: 'N8N_LOG_FILE_LOCATION', - }, - }, - }, - push: { backend: { format: ['sse', 'websocket'] as const, diff --git a/packages/cli/src/controllers/auth.controller.ts b/packages/cli/src/controllers/auth.controller.ts index 25f069ad20..c2ee1c92fb 100644 --- a/packages/cli/src/controllers/auth.controller.ts +++ b/packages/cli/src/controllers/auth.controller.ts @@ -14,7 +14,7 @@ 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 '@/logger'; +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 5137d5b4af..06c4f68c7e 100644 --- a/packages/cli/src/controllers/e2e.controller.ts +++ b/packages/cli/src/controllers/e2e.controller.ts @@ -14,7 +14,7 @@ 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 '@/logger'; +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 411ab7a03f..cbd2afb9f4 100644 --- a/packages/cli/src/controllers/invitation.controller.ts +++ b/packages/cli/src/controllers/invitation.controller.ts @@ -12,7 +12,7 @@ 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 '@/logger'; +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 b0d97bfdf2..6cbbda3622 100644 --- a/packages/cli/src/controllers/me.controller.ts +++ b/packages/cli/src/controllers/me.controller.ts @@ -16,7 +16,7 @@ import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; import type { PublicUser } from '@/interfaces'; -import { Logger } from '@/logger'; +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 b2c0d13f21..68a86269d3 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 @@ -15,7 +15,7 @@ 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 '@/logger'; +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 139ab9a983..9fc98d5557 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 @@ -15,7 +15,7 @@ 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 '@/logger'; +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 6750c7c2a3..6e162af988 100644 --- a/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts +++ b/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts @@ -15,7 +15,7 @@ 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 '@/logger'; +import { Logger } from '@/logging/logger.service'; import type { 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 76a0191359..47d50ad3f0 100644 --- a/packages/cli/src/controllers/owner.controller.ts +++ b/packages/cli/src/controllers/owner.controller.ts @@ -9,7 +9,7 @@ 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 '@/logger'; +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 ed566cf129..88155e420a 100644 --- a/packages/cli/src/controllers/password-reset.controller.ts +++ b/packages/cli/src/controllers/password-reset.controller.ts @@ -13,7 +13,7 @@ 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 '@/logger'; +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 c00fe48ad8..8e19be894d 100644 --- a/packages/cli/src/controllers/users.controller.ts +++ b/packages/cli/src/controllers/users.controller.ts @@ -18,7 +18,7 @@ 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 '@/logger'; +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 1268643b14..58c99727db 100644 --- a/packages/cli/src/controllers/workflow-statistics.controller.ts +++ b/packages/cli/src/controllers/workflow-statistics.controller.ts @@ -7,7 +7,7 @@ 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 '@/logger'; +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 184702c446..577a2f34fe 100644 --- a/packages/cli/src/crash-journal.ts +++ b/packages/cli/src/crash-journal.ts @@ -6,7 +6,7 @@ import { join, dirname } from 'path'; import { Container } from 'typedi'; import { inProduction } from '@/constants'; -import { Logger } from '@/logger'; +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 ec14bf7ecc..ed1b492dc6 100644 --- a/packages/cli/src/credentials-overwrites.ts +++ b/packages/cli/src/credentials-overwrites.ts @@ -5,7 +5,7 @@ import { Service } from 'typedi'; import { CredentialTypes } from '@/credential-types'; import type { ICredentialsOverwrite } from '@/interfaces'; -import { Logger } from '@/logger'; +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 41d9d163ba..76db501cf7 100644 --- a/packages/cli/src/credentials/credentials.controller.ts +++ b/packages/cli/src/credentials/credentials.controller.ts @@ -23,7 +23,7 @@ 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 '@/logger'; +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 dc5ab4e6c7..f9bbf89e57 100644 --- a/packages/cli/src/credentials/credentials.service.ts +++ b/packages/cli/src/credentials/credentials.service.ts @@ -33,7 +33,7 @@ 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 '@/logger'; +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/__tests__/execution.repository.test.ts b/packages/cli/src/databases/repositories/__tests__/execution.repository.test.ts index ac45b71bc4..48f3119780 100644 --- a/packages/cli/src/databases/repositories/__tests__/execution.repository.test.ts +++ b/packages/cli/src/databases/repositories/__tests__/execution.repository.test.ts @@ -12,7 +12,7 @@ import { mockInstance, mockEntityManager } from '@test/mocking'; describe('ExecutionRepository', () => { const entityManager = mockEntityManager(ExecutionEntity); - const globalConfig = mockInstance(GlobalConfig); + const globalConfig = mockInstance(GlobalConfig, { logging: { outputs: ['console'] } }); const binaryDataService = mockInstance(BinaryDataService); const executionRepository = Container.get(ExecutionRepository); const mockDate = new Date('2023-12-28 12:34:56.789Z'); diff --git a/packages/cli/src/databases/repositories/execution.repository.ts b/packages/cli/src/databases/repositories/execution.repository.ts index 7a67b71ace..aee2752494 100644 --- a/packages/cli/src/databases/repositories/execution.repository.ts +++ b/packages/cli/src/databases/repositories/execution.repository.ts @@ -47,7 +47,7 @@ import type { IExecutionFlattedDb, IExecutionResponse, } from '@/interfaces'; -import { Logger } from '@/logger'; +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 4bb2cc98d3..2f9e698890 100644 --- a/packages/cli/src/databases/subscribers/user-subscriber.ts +++ b/packages/cli/src/databases/subscribers/user-subscriber.ts @@ -3,7 +3,7 @@ import { EventSubscriber } from '@n8n/typeorm'; import { ApplicationError, ErrorReporterProxy } from 'n8n-workflow'; import { Container } from 'typedi'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { Project } from '../entities/project'; import { User } from '../entities/user'; diff --git a/packages/cli/src/databases/types.ts b/packages/cli/src/databases/types.ts index 21bfdc025a..2bb1802bf2 100644 --- a/packages/cli/src/databases/types.ts +++ b/packages/cli/src/databases/types.ts @@ -1,7 +1,7 @@ import type { QueryRunner, ObjectLiteral } from '@n8n/typeorm'; import type { INodeTypes } from 'n8n-workflow'; -import type { Logger } from '@/logger'; +import type { Logger } from '@/logging/logger.service'; import type { createSchemaBuilder } from './dsl'; diff --git a/packages/cli/src/databases/utils/migration-helpers.ts b/packages/cli/src/databases/utils/migration-helpers.ts index 9d29e3fbe5..1093096f43 100644 --- a/packages/cli/src/databases/utils/migration-helpers.ts +++ b/packages/cli/src/databases/utils/migration-helpers.ts @@ -9,7 +9,7 @@ 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 '@/logger'; +import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; const PERSONALIZATION_SURVEY_FILENAME = 'personalizationSurvey.json'; 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 321534ff6c..9c495bbb8d 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 @@ -11,7 +11,7 @@ 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 '@/logger'; +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 14cdb9e81a..99571cdd52 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 @@ -14,7 +14,7 @@ import type { import { Service } from 'typedi'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logger'; +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 29393c5efe..35298d560a 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 @@ -4,7 +4,7 @@ import path from 'path'; import { Container } from 'typedi'; import { License } from '@/license'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { SOURCE_CONTROL_GIT_KEY_COMMENT, 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 fb491f39d2..b08ae27dd8 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 @@ -23,7 +23,7 @@ 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 '@/logger'; +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 a99c5fb3e8..d3a34d784f 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 @@ -9,7 +9,7 @@ import Container, { Service } from 'typedi'; import config from '@/config'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { Logger } from '@/logger'; +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 11340a0e15..32f0b39ef7 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 @@ -10,7 +10,7 @@ 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 '@/logger'; +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 d901346d7e..4046855f30 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 @@ -2,7 +2,7 @@ import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; import { Container } from 'typedi'; import type { EventDestinations } from '@/databases/entities/event-destinations'; -import { Logger } from '@/logger'; +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 dc1727cb0c..83db469d79 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 @@ -7,7 +7,7 @@ import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; import syslog from 'syslog-client'; import Container from 'typedi'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { MessageEventBusDestination } from './message-event-bus-destination.ee'; import { eventMessageGenericDestinationTestEvent } from '../event-message-classes/event-message-generic'; 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 4d6725ff2c..7b65767b04 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 @@ -5,7 +5,7 @@ import { v4 as uuid } from 'uuid'; import { EventDestinationsRepository } from '@/databases/repositories/event-destinations.repository'; import { License } from '@/license'; -import { Logger } from '@/logger'; +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 6b009f38e9..b9177faa07 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 @@ -12,7 +12,7 @@ import Container from 'typedi'; import { Worker } from 'worker_threads'; import { inTest } from '@/constants'; -import { Logger } from '@/logger'; +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 fec5b4845b..0f622c2317 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 @@ -13,7 +13,7 @@ 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 '@/logger'; +import { Logger } from '@/logging/logger.service'; import { OrchestrationService } from '@/services/orchestration.service'; import { ExecutionRecoveryService } from '../../executions/execution-recovery.service'; diff --git a/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts b/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts index 124afd901b..6eecb8e812 100644 --- a/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts +++ b/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts @@ -37,6 +37,10 @@ describe('TelemetryEventRelay', () => { includeQueueMetrics: false, }, }, + logging: { + level: 'info', + outputs: ['console'], + }, }); const workflowRepository = mock(); const nodeTypes = mock(); 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 80e620fb17..c8e6b3e88f 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 @@ -9,7 +9,7 @@ import { ExecutionRepository } from '@/databases/repositories/execution.reposito 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 '@/logger'; +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 31b045ade8..d9a1a9a0e9 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 @@ -4,7 +4,7 @@ import type { IRun, WorkflowExecuteMode } from 'n8n-workflow'; import Container from 'typedi'; import config from '@/config'; -import { Logger } from '@/logger'; +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 212990211f..ca9899e1ec 100644 --- a/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts +++ b/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts @@ -4,7 +4,7 @@ import { Container } from 'typedi'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { toSaveSettings } from '@/execution-lifecycle-hooks/to-save-settings'; -import { Logger } from '@/logger'; +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 2888f7bd28..9596dd35df 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 @@ -4,7 +4,7 @@ import { Container } from 'typedi'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import type { IExecutionDb, UpdateExecutionPayload } from '@/interfaces'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { ExecutionMetadataService } from '@/services/execution-metadata.service'; import { isWorkflowIdValid } from '@/utils'; diff --git a/packages/cli/src/executions/execution-recovery.service.ts b/packages/cli/src/executions/execution-recovery.service.ts index e1e6a1f180..33576d1368 100644 --- a/packages/cli/src/executions/execution-recovery.service.ts +++ b/packages/cli/src/executions/execution-recovery.service.ts @@ -10,7 +10,7 @@ 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 '@/logger'; +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 be685befc9..5f4ec0c535 100644 --- a/packages/cli/src/executions/execution.service.ts +++ b/packages/cli/src/executions/execution.service.ts @@ -38,7 +38,7 @@ import type { IWorkflowDb, } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logger'; +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 76db778d0a..e175f2969c 100644 --- a/packages/cli/src/external-secrets/external-secrets-manager.ee.ts +++ b/packages/cli/src/external-secrets/external-secrets-manager.ee.ts @@ -10,7 +10,7 @@ import type { SecretsProviderSettings, } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { OrchestrationService } from '@/services/orchestration.service'; import { EXTERNAL_SECRETS_INITIAL_BACKOFF, EXTERNAL_SECRETS_MAX_BACKOFF } from './constants'; diff --git a/packages/cli/src/external-secrets/providers/vault.ts b/packages/cli/src/external-secrets/providers/vault.ts index e325e69935..398c40745d 100644 --- a/packages/cli/src/external-secrets/providers/vault.ts +++ b/packages/cli/src/external-secrets/providers/vault.ts @@ -5,7 +5,7 @@ import { Container } from 'typedi'; import type { SecretsProviderSettings, SecretsProviderState } from '@/interfaces'; import { SecretsProvider } from '@/interfaces'; -import { Logger } from '@/logger'; +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/ldap/ldap.service.ee.ts b/packages/cli/src/ldap/ldap.service.ee.ts index 84c79c7651..b552db6974 100644 --- a/packages/cli/src/ldap/ldap.service.ee.ts +++ b/packages/cli/src/ldap/ldap.service.ee.ts @@ -14,7 +14,7 @@ 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 '@/logger'; +import { Logger } from '@/logging/logger.service'; import { getCurrentAuthenticationMethod, isEmailCurrentAuthenticationMethod, diff --git a/packages/cli/src/license.ts b/packages/cli/src/license.ts index 81fb9eb608..0cde2bd922 100644 --- a/packages/cli/src/license.ts +++ b/packages/cli/src/license.ts @@ -6,7 +6,7 @@ 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 '@/logger'; +import { Logger } from '@/logging/logger.service'; import { LicenseMetricsService } from '@/metrics/license-metrics.service'; import { OrchestrationService } from '@/services/orchestration.service'; diff --git a/packages/cli/src/license/license.service.ts b/packages/cli/src/license/license.service.ts index d92c181f8d..ee0e27bccb 100644 --- a/packages/cli/src/license/license.service.ts +++ b/packages/cli/src/license/license.service.ts @@ -6,7 +6,7 @@ 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 '@/logger'; +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 871913afba..662558e3d6 100644 --- a/packages/cli/src/load-nodes-and-credentials.ts +++ b/packages/cli/src/load-nodes-and-credentials.ts @@ -28,7 +28,7 @@ import { CLI_DIR, inE2ETests, } from '@/constants'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; interface LoadedNodesAndCredentials { nodes: INodeTypeData; diff --git a/packages/cli/src/logger.ts b/packages/cli/src/logger.ts deleted file mode 100644 index 7a24bdbf28..0000000000 --- a/packages/cli/src/logger.ts +++ /dev/null @@ -1,117 +0,0 @@ -import callsites from 'callsites'; -import { LoggerProxy, type IDataObject, LOG_LEVELS } from 'n8n-workflow'; -import { basename } from 'path'; -import { Service } from 'typedi'; -import { inspect } from 'util'; -import winston from 'winston'; - -import config from '@/config'; - -const noOp = () => {}; - -@Service() -export class Logger { - private logger: winston.Logger; - - constructor() { - const level = config.getEnv('logs.level'); - - this.logger = winston.createLogger({ - level, - silent: level === 'silent', - }); - - // Change all methods with higher log-level to no-op - for (const levelName of LOG_LEVELS) { - if (this.logger.levels[levelName] > this.logger.levels[level]) { - Object.defineProperty(this, levelName, { value: noOp }); - } - } - - const output = config - .getEnv('logs.output') - .split(',') - .map((line) => line.trim()); - - if (output.includes('console')) { - let format: winston.Logform.Format; - if (level === 'debug') { - format = winston.format.combine( - winston.format.metadata(), - winston.format.timestamp(), - winston.format.colorize({ all: true }), - - winston.format.printf(({ level: logLevel, message, timestamp, metadata }) => { - return `${timestamp} | ${logLevel.padEnd(18)} | ${message}${ - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - Object.keys(metadata).length ? ` ${JSON.stringify(inspect(metadata))}` : '' - }`; - }), - ); - } else { - format = winston.format.printf(({ message }: { message: string }) => message); - } - - this.logger.add( - new winston.transports.Console({ - format, - }), - ); - } - - if (output.includes('file')) { - const fileLogFormat = winston.format.combine( - winston.format.timestamp(), - winston.format.metadata(), - winston.format.json(), - ); - this.logger.add( - new winston.transports.File({ - filename: config.getEnv('logs.file.location'), - format: fileLogFormat, - maxsize: config.getEnv('logs.file.fileSizeMax') * 1048576, // config * 1mb - maxFiles: config.getEnv('logs.file.fileCountMax'), - }), - ); - } - - LoggerProxy.init(this); - } - - private log(level: (typeof LOG_LEVELS)[number], message: string, meta: object = {}): void { - const callsite = callsites(); - // We are using the third array element as the structure is as follows: - // [0]: this file - // [1]: Should be Logger - // [2]: Should point to the caller. - // Note: getting line number is useless because at this point - // We are in runtime, so it means we are looking at compiled js files - const logDetails = {} as IDataObject; - if (callsite[2] !== undefined) { - logDetails.file = basename(callsite[2].getFileName() || ''); - const functionName = callsite[2].getFunctionName(); - if (functionName) { - logDetails.function = functionName; - } - } - this.logger.log(level, message, { ...meta, ...logDetails }); - } - - // Convenience methods below - - error(message: string, meta: object = {}): void { - this.log('error', message, meta); - } - - warn(message: string, meta: object = {}): void { - this.log('warn', message, meta); - } - - info(message: string, meta: object = {}): void { - this.log('info', message, meta); - } - - debug(message: string, meta: object = {}): void { - this.log('debug', message, meta); - } -} diff --git a/packages/cli/src/logging/__tests__/logger.service.test.ts b/packages/cli/src/logging/__tests__/logger.service.test.ts new file mode 100644 index 0000000000..f699443909 --- /dev/null +++ b/packages/cli/src/logging/__tests__/logger.service.test.ts @@ -0,0 +1,145 @@ +import type { GlobalConfig } from '@n8n/config'; +import { mock } from 'jest-mock-extended'; +import type { InstanceSettings } from 'n8n-core'; + +import { Logger } from '@/logging/logger.service'; + +describe('Logger', () => { + describe('transports', () => { + test('if `console` selected, should set console transport', () => { + const globalConfig = mock({ + logging: { + level: 'info', + outputs: ['console'], + }, + }); + + const logger = new Logger(globalConfig, mock()); + + const { transports } = logger.getInternalLogger(); + + expect(transports).toHaveLength(1); + + const [transport] = transports; + + expect(transport.constructor.name).toBe('Console'); + }); + + test('if `file` selected, should set file transport', () => { + const globalConfig = mock({ + logging: { + level: 'info', + outputs: ['file'], + file: { + fileSizeMax: 100, + fileCountMax: 16, + location: 'logs/n8n.log', + }, + }, + }); + + const logger = new Logger(globalConfig, mock({ n8nFolder: '/tmp' })); + + const { transports } = logger.getInternalLogger(); + + expect(transports).toHaveLength(1); + + const [transport] = transports; + + expect(transport.constructor.name).toBe('File'); + }); + }); + + describe('levels', () => { + test('if `error` selected, should enable `error` level', () => { + const globalConfig = mock({ + logging: { + level: 'error', + outputs: ['console'], + }, + }); + + const logger = new Logger(globalConfig, mock()); + + const internalLogger = logger.getInternalLogger(); + + expect(internalLogger.isErrorEnabled()).toBe(true); + expect(internalLogger.isWarnEnabled()).toBe(false); + expect(internalLogger.isInfoEnabled()).toBe(false); + expect(internalLogger.isDebugEnabled()).toBe(false); + }); + + test('if `warn` selected, should enable `error` and `warn` levels', () => { + const globalConfig = mock({ + logging: { + level: 'warn', + outputs: ['console'], + }, + }); + + const logger = new Logger(globalConfig, mock()); + + const internalLogger = logger.getInternalLogger(); + + expect(internalLogger.isErrorEnabled()).toBe(true); + expect(internalLogger.isWarnEnabled()).toBe(true); + expect(internalLogger.isInfoEnabled()).toBe(false); + expect(internalLogger.isDebugEnabled()).toBe(false); + }); + + test('if `info` selected, should enable `error`, `warn`, and `info` levels', () => { + const globalConfig = mock({ + logging: { + level: 'info', + outputs: ['console'], + }, + }); + + const logger = new Logger(globalConfig, mock()); + + const internalLogger = logger.getInternalLogger(); + + expect(internalLogger.isErrorEnabled()).toBe(true); + expect(internalLogger.isWarnEnabled()).toBe(true); + expect(internalLogger.isInfoEnabled()).toBe(true); + expect(internalLogger.isDebugEnabled()).toBe(false); + }); + + test('if `debug` selected, should enable all levels', () => { + const globalConfig = mock({ + logging: { + level: 'debug', + outputs: ['console'], + }, + }); + + const logger = new Logger(globalConfig, mock()); + + const internalLogger = logger.getInternalLogger(); + + expect(internalLogger.isErrorEnabled()).toBe(true); + expect(internalLogger.isWarnEnabled()).toBe(true); + expect(internalLogger.isInfoEnabled()).toBe(true); + expect(internalLogger.isDebugEnabled()).toBe(true); + }); + + test('if `silent` selected, should disable all levels', () => { + const globalConfig = mock({ + logging: { + level: 'silent', + outputs: ['console'], + }, + }); + + const logger = new Logger(globalConfig, mock()); + + const internalLogger = logger.getInternalLogger(); + + expect(internalLogger.isErrorEnabled()).toBe(false); + expect(internalLogger.isWarnEnabled()).toBe(false); + expect(internalLogger.isInfoEnabled()).toBe(false); + expect(internalLogger.isDebugEnabled()).toBe(false); + expect(internalLogger.silent).toBe(true); + }); + }); +}); diff --git a/packages/cli/src/logging/constants.ts b/packages/cli/src/logging/constants.ts new file mode 100644 index 0000000000..107327694b --- /dev/null +++ b/packages/cli/src/logging/constants.ts @@ -0,0 +1,3 @@ +export const noOp = () => {}; + +export const LOG_LEVELS = ['error', 'warn', 'info', 'debug', 'silent'] as const; diff --git a/packages/cli/src/logging/logger.service.ts b/packages/cli/src/logging/logger.service.ts new file mode 100644 index 0000000000..9a1b804859 --- /dev/null +++ b/packages/cli/src/logging/logger.service.ts @@ -0,0 +1,148 @@ +import { GlobalConfig } from '@n8n/config'; +import callsites from 'callsites'; +import { InstanceSettings } from 'n8n-core'; +import { LoggerProxy, LOG_LEVELS } from 'n8n-workflow'; +import path, { basename } from 'node:path'; +import { Service } from 'typedi'; +import winston from 'winston'; + +import { isObjectLiteral } from '@/utils'; + +import { noOp } from './constants'; +import type { LogLocationMetadata, LogLevel, LogMetadata } from './types'; + +@Service() +export class Logger { + private readonly internalLogger: winston.Logger; + + private readonly level: LogLevel; + + constructor( + private readonly globalConfig: GlobalConfig, + private readonly instanceSettings: InstanceSettings, + ) { + this.level = this.globalConfig.logging.level; + + const isSilent = this.level === 'silent'; + + this.internalLogger = winston.createLogger({ + level: this.level, + silent: isSilent, + }); + + if (!isSilent) { + this.setLevel(); + + const { outputs } = this.globalConfig.logging; + + if (outputs.includes('console')) this.setConsoleTransport(); + if (outputs.includes('file')) this.setFileTransport(); + } + + LoggerProxy.init(this); + } + + private log(level: LogLevel, message: string, metadata: LogMetadata) { + const location: LogLocationMetadata = {}; + + const caller = callsites().at(2); // zeroth and first are this file, second is caller + + if (caller !== undefined) { + location.file = basename(caller.getFileName() ?? ''); + const fnName = caller.getFunctionName(); + if (fnName) location.function = fnName; + } + + this.internalLogger.log(level, message, { ...metadata, ...location }); + } + + private setLevel() { + const { levels } = this.internalLogger; + + for (const logLevel of LOG_LEVELS) { + if (levels[logLevel] > levels[this.level]) { + // winston defines `{ error: 0, warn: 1, info: 2, debug: 5 }` + // so numerically higher (less severe) log levels become no-op + // to prevent overhead from `callsites` calls + Object.defineProperty(this, logLevel, { value: noOp }); + } + } + } + + private setConsoleTransport() { + const format = + this.level === 'debug' + ? winston.format.combine( + winston.format.metadata(), + winston.format.timestamp(), + winston.format.colorize({ all: true }), + winston.format.printf(({ level, message, timestamp, metadata }) => { + const _metadata = this.toPrintable(metadata); + return `${timestamp} | ${level.padEnd(18)} | ${message}${_metadata}`; + }), + ) + : winston.format.printf(({ message }: { message: string }) => message); + + this.internalLogger.add(new winston.transports.Console({ format })); + } + + private toPrintable(metadata: unknown) { + if (isObjectLiteral(metadata) && Object.keys(metadata).length > 0) { + return ' ' + JSON.stringify(metadata); + } + + return ''; + } + + private setFileTransport() { + const format = winston.format.combine( + winston.format.timestamp(), + winston.format.metadata(), + winston.format.json(), + ); + + const filename = path.join( + this.instanceSettings.n8nFolder, + this.globalConfig.logging.file.location, + ); + + const { fileSizeMax, fileCountMax } = this.globalConfig.logging.file; + + this.internalLogger.add( + new winston.transports.File({ + filename, + format, + maxsize: fileSizeMax * 1_048_576, // config * 1 MiB in bytes + maxFiles: fileCountMax, + }), + ); + } + + // #region Convenience methods + + error(message: string, metadata: LogMetadata = {}) { + this.log('error', message, metadata); + } + + warn(message: string, metadata: LogMetadata = {}) { + this.log('warn', message, metadata); + } + + info(message: string, metadata: LogMetadata = {}) { + this.log('info', message, metadata); + } + + debug(message: string, metadata: LogMetadata = {}) { + this.log('debug', message, metadata); + } + + // #endregion + + // #region For testing only + + getInternalLogger() { + return this.internalLogger; + } + + // #endregion +} diff --git a/packages/cli/src/logging/types.ts b/packages/cli/src/logging/types.ts new file mode 100644 index 0000000000..94b02d8ad7 --- /dev/null +++ b/packages/cli/src/logging/types.ts @@ -0,0 +1,7 @@ +import type { LOG_LEVELS } from './constants'; + +export type LogLevel = (typeof LOG_LEVELS)[number]; + +export type LogLocationMetadata = Partial<{ file: string; function: string }>; + +export type LogMetadata = Record | Error; diff --git a/packages/cli/src/posthog/__tests__/posthog.test.ts b/packages/cli/src/posthog/__tests__/posthog.test.ts index f2869afcbf..5c8fe282bf 100644 --- a/packages/cli/src/posthog/__tests__/posthog.test.ts +++ b/packages/cli/src/posthog/__tests__/posthog.test.ts @@ -1,3 +1,5 @@ +import type { GlobalConfig } from '@n8n/config'; +import { mock } from 'jest-mock-extended'; import { InstanceSettings } from 'n8n-core'; import { PostHog } from 'posthog-node'; @@ -15,6 +17,8 @@ describe('PostHog', () => { const instanceSettings = mockInstance(InstanceSettings, { instanceId }); + const globalConfig = mock({ logging: { level: 'debug' } }); + beforeAll(() => { config.set('diagnostics.config.posthog.apiKey', apiKey); config.set('diagnostics.config.posthog.apiHost', apiHost); @@ -26,7 +30,7 @@ describe('PostHog', () => { }); it('inits PostHog correctly', async () => { - const ph = new PostHogClient(instanceSettings); + const ph = new PostHogClient(instanceSettings, globalConfig); await ph.init(); expect(PostHog.prototype.constructor).toHaveBeenCalledWith(apiKey, { host: apiHost }); @@ -35,7 +39,7 @@ describe('PostHog', () => { it('does not initialize or track if diagnostics are not enabled', async () => { config.set('diagnostics.enabled', false); - const ph = new PostHogClient(instanceSettings); + const ph = new PostHogClient(instanceSettings, globalConfig); await ph.init(); ph.track({ @@ -55,7 +59,7 @@ describe('PostHog', () => { test: true, }; - const ph = new PostHogClient(instanceSettings); + const ph = new PostHogClient(instanceSettings, globalConfig); await ph.init(); ph.track({ @@ -75,7 +79,7 @@ describe('PostHog', () => { it('gets feature flags', async () => { const createdAt = new Date(); - const ph = new PostHogClient(instanceSettings); + const ph = new PostHogClient(instanceSettings, globalConfig); await ph.init(); await ph.getFeatureFlags({ diff --git a/packages/cli/src/posthog/index.ts b/packages/cli/src/posthog/index.ts index 08a501f0fc..8dec9755b3 100644 --- a/packages/cli/src/posthog/index.ts +++ b/packages/cli/src/posthog/index.ts @@ -1,3 +1,4 @@ +import { GlobalConfig } from '@n8n/config'; import { InstanceSettings } from 'n8n-core'; import type { FeatureFlags, ITelemetryTrackProperties } from 'n8n-workflow'; import type { PostHog } from 'posthog-node'; @@ -10,7 +11,10 @@ import type { PublicUser } from '@/interfaces'; export class PostHogClient { private postHog?: PostHog; - constructor(private readonly instanceSettings: InstanceSettings) {} + constructor( + private readonly instanceSettings: InstanceSettings, + private readonly globalConfig: GlobalConfig, + ) {} async init() { const enabled = config.getEnv('diagnostics.enabled'); @@ -23,7 +27,7 @@ export class PostHogClient { host: config.getEnv('diagnostics.config.posthog.apiHost'), }); - const logLevel = config.getEnv('logs.level'); + const logLevel = this.globalConfig.logging.level; if (logLevel === 'debug') { this.postHog.debug(true); } diff --git a/packages/cli/src/push/__tests__/websocket.push.test.ts b/packages/cli/src/push/__tests__/websocket.push.test.ts index f62038c6b3..209f91b17e 100644 --- a/packages/cli/src/push/__tests__/websocket.push.test.ts +++ b/packages/cli/src/push/__tests__/websocket.push.test.ts @@ -4,7 +4,7 @@ import { Container } from 'typedi'; import type WebSocket from 'ws'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logger'; +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 f3ae6606ed..c56fa4c042 100644 --- a/packages/cli/src/push/abstract.push.ts +++ b/packages/cli/src/push/abstract.push.ts @@ -2,7 +2,7 @@ import type { PushPayload, PushType } from '@n8n/api-types'; import { assert, jsonStringify } from 'n8n-workflow'; import type { User } from '@/databases/entities/user'; -import type { Logger } from '@/logger'; +import type { Logger } from '@/logging/logger.service'; import type { OnPushMessage } from '@/push/types'; import { TypedEmitter } from '@/typed-emitter'; diff --git a/packages/cli/src/push/sse.push.ts b/packages/cli/src/push/sse.push.ts index 96af003b4b..85d16a3b42 100644 --- a/packages/cli/src/push/sse.push.ts +++ b/packages/cli/src/push/sse.push.ts @@ -1,7 +1,7 @@ import { Service } from 'typedi'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import SSEChannel from 'sse-channel'; import { AbstractPush } from './abstract.push'; diff --git a/packages/cli/src/push/websocket.push.ts b/packages/cli/src/push/websocket.push.ts index 013663cab6..dc60d70901 100644 --- a/packages/cli/src/push/websocket.push.ts +++ b/packages/cli/src/push/websocket.push.ts @@ -3,7 +3,7 @@ import { Service } from 'typedi'; import type WebSocket from 'ws'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { AbstractPush } from './abstract.push'; diff --git a/packages/cli/src/response-helper.ts b/packages/cli/src/response-helper.ts index c9f7270d5f..0dff1625cb 100644 --- a/packages/cli/src/response-helper.ts +++ b/packages/cli/src/response-helper.ts @@ -10,9 +10,9 @@ 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'; -import { Logger } from './logger'; export function sendSuccessResponse( res: Response, diff --git a/packages/cli/src/scaling/job-processor.ts b/packages/cli/src/scaling/job-processor.ts index 1d0bccc6bf..49e1383ac6 100644 --- a/packages/cli/src/scaling/job-processor.ts +++ b/packages/cli/src/scaling/job-processor.ts @@ -8,7 +8,7 @@ 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 '@/logger'; +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/pubsub/publisher.service.ts b/packages/cli/src/scaling/pubsub/publisher.service.ts index 09bf06e4f5..7a35b94c3e 100644 --- a/packages/cli/src/scaling/pubsub/publisher.service.ts +++ b/packages/cli/src/scaling/pubsub/publisher.service.ts @@ -2,7 +2,7 @@ import type { Redis as SingleNodeClient, Cluster as MultiNodeClient } from 'iore import { Service } from 'typedi'; import config from '@/config'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; 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 3605e71f31..fe3b22b479 100644 --- a/packages/cli/src/scaling/pubsub/subscriber.service.ts +++ b/packages/cli/src/scaling/pubsub/subscriber.service.ts @@ -2,7 +2,7 @@ import type { Redis as SingleNodeClient, Cluster as MultiNodeClient } from 'iore import { Service } from 'typedi'; import config from '@/config'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; 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 6a383fb353..b7c4034afa 100644 --- a/packages/cli/src/scaling/scaling.service.ts +++ b/packages/cli/src/scaling/scaling.service.ts @@ -11,7 +11,7 @@ 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 '@/logger'; +import { Logger } from '@/logging/logger.service'; import { OrchestrationService } from '@/services/orchestration.service'; import { JOB_TYPE_NAME, QUEUE_NAME } from './constants'; diff --git a/packages/cli/src/scaling/worker-server.ts b/packages/cli/src/scaling/worker-server.ts index abc6a3a024..4d27a82a1c 100644 --- a/packages/cli/src/scaling/worker-server.ts +++ b/packages/cli/src/scaling/worker-server.ts @@ -16,7 +16,7 @@ import { PortTakenError } from '@/errors/port-taken.error'; import { ServiceUnavailableError } from '@/errors/response-errors/service-unavailable.error'; import { ExternalHooks } from '@/external-hooks'; import type { ICredentialsOverwrite } from '@/interfaces'; -import { Logger } from '@/logger'; +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 4792bf8b6a..b0d6ccfad3 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 @@ -6,7 +6,7 @@ import { Service } from 'typedi'; import config from '@/config'; import { getN8nPackageJson, inDevelopment } from '@/constants'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import { Logger } from '@/logger'; +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 f2aaf9293d..61aa875d1a 100644 --- a/packages/cli/src/services/active-workflows.service.ts +++ b/packages/cli/src/services/active-workflows.service.ts @@ -5,7 +5,7 @@ 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 '@/logger'; +import { Logger } from '@/logging/logger.service'; @Service() export class ActiveWorkflowsService { diff --git a/packages/cli/src/services/ai-assistant.service.ts b/packages/cli/src/services/ai-assistant.service.ts index 77234165c1..76b6e3fffb 100644 --- a/packages/cli/src/services/ai-assistant.service.ts +++ b/packages/cli/src/services/ai-assistant.service.ts @@ -1,3 +1,4 @@ +import { GlobalConfig } from '@n8n/config'; import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk'; import { AiAssistantClient } from '@n8n_io/ai-assistant-sdk'; import { assert, type IUser } from 'n8n-workflow'; @@ -14,7 +15,10 @@ import { License } from '../license'; export class AiAssistantService { private client: AiAssistantClient | undefined; - constructor(private readonly licenseService: License) {} + constructor( + private readonly licenseService: License, + private readonly globalConfig: GlobalConfig, + ) {} async init() { const aiAssistantEnabled = this.licenseService.isAiAssistantEnabled(); @@ -25,7 +29,7 @@ export class AiAssistantService { const licenseCert = await this.licenseService.loadCertStr(); const consumerId = this.licenseService.getConsumerId(); const baseUrl = config.get('aiAssistant.baseUrl'); - const logLevel = config.getEnv('logs.level'); + const logLevel = this.globalConfig.logging.level; this.client = new AiAssistantClient({ licenseCert, diff --git a/packages/cli/src/services/community-packages.service.ts b/packages/cli/src/services/community-packages.service.ts index 500518ae02..b157119cf2 100644 --- a/packages/cli/src/services/community-packages.service.ts +++ b/packages/cli/src/services/community-packages.service.ts @@ -22,7 +22,7 @@ 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 '@/logger'; +import { Logger } from '@/logging/logger.service'; import { toError } from '@/utils'; import { OrchestrationService } from './orchestration.service'; diff --git a/packages/cli/src/services/credentials-tester.service.ts b/packages/cli/src/services/credentials-tester.service.ts index b66d4a474f..30504e464b 100644 --- a/packages/cli/src/services/credentials-tester.service.ts +++ b/packages/cli/src/services/credentials-tester.service.ts @@ -35,7 +35,7 @@ import { Service } from 'typedi'; import { CredentialTypes } from '@/credential-types'; import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logger'; +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 6ac3a1863c..600059422a 100644 --- a/packages/cli/src/services/frontend.service.ts +++ b/packages/cli/src/services/frontend.service.ts @@ -17,7 +17,7 @@ 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 '@/logger'; +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'; @@ -123,7 +123,7 @@ export class FrontendService { apiKey: config.getEnv('diagnostics.config.posthog.apiKey'), autocapture: false, disableSessionRecording: config.getEnv('deployment.type') !== 'cloud', - debug: config.getEnv('logs.level') === 'debug', + debug: this.globalConfig.logging.level === 'debug', }, personalizationSurveyEnabled: config.getEnv('personalization.enabled') && config.getEnv('diagnostics.enabled'), @@ -153,7 +153,7 @@ export class FrontendService { }, }, workflowTagsDisabled: config.getEnv('workflowTagsDisabled'), - logLevel: config.getEnv('logs.level'), + logLevel: this.globalConfig.logging.level, hiringBannerEnabled: config.getEnv('hiringBanner.enabled'), aiAssistant: { enabled: false, diff --git a/packages/cli/src/services/import.service.ts b/packages/cli/src/services/import.service.ts index 5691fc941c..a486ff8396 100644 --- a/packages/cli/src/services/import.service.ts +++ b/packages/cli/src/services/import.service.ts @@ -11,7 +11,7 @@ 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 '@/logger'; +import { Logger } from '@/logging/logger.service'; import { replaceInvalidCredentials } from '@/workflow-helpers'; @Service() diff --git a/packages/cli/src/services/orchestration.service.ts b/packages/cli/src/services/orchestration.service.ts index bc42d871c3..666fe48ac6 100644 --- a/packages/cli/src/services/orchestration.service.ts +++ b/packages/cli/src/services/orchestration.service.ts @@ -4,7 +4,7 @@ import Container, { Service } from 'typedi'; import config from '@/config'; import type { PubSubCommandMap } from '@/events/maps/pub-sub.event-map'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import type { Publisher } from '@/scaling/pubsub/publisher.service'; import type { Subscriber } from '@/scaling/pubsub/subscriber.service'; diff --git a/packages/cli/src/services/orchestration/helpers.ts b/packages/cli/src/services/orchestration/helpers.ts index a5470138dc..f36bb4adf9 100644 --- a/packages/cli/src/services/orchestration/helpers.ts +++ b/packages/cli/src/services/orchestration/helpers.ts @@ -2,7 +2,7 @@ import { jsonParse } from 'n8n-workflow'; import os from 'node:os'; import { Container } from 'typedi'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { COMMAND_PUBSUB_CHANNEL } from '@/scaling/constants'; import type { PubSub } from '@/scaling/pubsub/pubsub.types'; diff --git a/packages/cli/src/services/orchestration/main/handle-command-message-main.ts b/packages/cli/src/services/orchestration/main/handle-command-message-main.ts index 49fce27aef..909f5976a5 100644 --- a/packages/cli/src/services/orchestration/main/handle-command-message-main.ts +++ b/packages/cli/src/services/orchestration/main/handle-command-message-main.ts @@ -7,7 +7,7 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; import { License } from '@/license'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { Push } from '@/push'; import { CommunityPackagesService } from '@/services/community-packages.service'; import { OrchestrationService } from '@/services/orchestration.service'; diff --git a/packages/cli/src/services/orchestration/main/handle-worker-response-message-main.ts b/packages/cli/src/services/orchestration/main/handle-worker-response-message-main.ts index 7842c71463..a3b5912fb4 100644 --- a/packages/cli/src/services/orchestration/main/handle-worker-response-message-main.ts +++ b/packages/cli/src/services/orchestration/main/handle-worker-response-message-main.ts @@ -1,7 +1,7 @@ import { jsonParse } from 'n8n-workflow'; import Container from 'typedi'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { WORKER_RESPONSE_PUBSUB_CHANNEL } from '@/scaling/constants'; import type { PubSub } from '@/scaling/pubsub/pubsub.types'; diff --git a/packages/cli/src/services/orchestration/main/multi-main-setup.ee.ts b/packages/cli/src/services/orchestration/main/multi-main-setup.ee.ts index 98dbce7fde..bb1b52519c 100644 --- a/packages/cli/src/services/orchestration/main/multi-main-setup.ee.ts +++ b/packages/cli/src/services/orchestration/main/multi-main-setup.ee.ts @@ -4,7 +4,7 @@ import { Service } from 'typedi'; import config from '@/config'; import { TIME } from '@/constants'; -import { Logger } from '@/logger'; +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/services/orchestration/worker/handle-command-message-worker.ts b/packages/cli/src/services/orchestration/worker/handle-command-message-worker.ts index 3c5b108010..ae11ac96fe 100644 --- a/packages/cli/src/services/orchestration/worker/handle-command-message-worker.ts +++ b/packages/cli/src/services/orchestration/worker/handle-command-message-worker.ts @@ -6,7 +6,7 @@ import { N8N_VERSION } from '@/constants'; import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; import { License } from '@/license'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { COMMAND_PUBSUB_CHANNEL } from '@/scaling/constants'; import type { PubSub } from '@/scaling/pubsub/pubsub.types'; import { CommunityPackagesService } from '@/services/community-packages.service'; diff --git a/packages/cli/src/services/pruning.service.ts b/packages/cli/src/services/pruning.service.ts index b0ebc99dfd..48d4b0db3b 100644 --- a/packages/cli/src/services/pruning.service.ts +++ b/packages/cli/src/services/pruning.service.ts @@ -6,7 +6,7 @@ import config from '@/config'; import { inTest, TIME } from '@/constants'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { OnShutdown } from '@/decorators/on-shutdown'; -import { Logger } from '@/logger'; +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 1eb083a2d7..f205a756c5 100644 --- a/packages/cli/src/services/redis-client.service.ts +++ b/packages/cli/src/services/redis-client.service.ts @@ -4,7 +4,7 @@ import type { Cluster, RedisOptions } from 'ioredis'; import { Service } from 'typedi'; import { Debounce } from '@/decorators/debounce'; -import { Logger } from '@/logger'; +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 3d8fde6c00..1668878a8c 100644 --- a/packages/cli/src/services/user.service.ts +++ b/packages/cli/src/services/user.service.ts @@ -7,7 +7,7 @@ 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 '@/logger'; +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 42c6d14638..1beead137c 100644 --- a/packages/cli/src/services/workflow-statistics.service.ts +++ b/packages/cli/src/services/workflow-statistics.service.ts @@ -4,7 +4,7 @@ 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 '@/logger'; +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 8e2c1f3884..1bedc3a7d4 100644 --- a/packages/cli/src/shutdown/shutdown.service.ts +++ b/packages/cli/src/shutdown/shutdown.service.ts @@ -3,7 +3,7 @@ import { ApplicationError, ErrorReporterProxy, assert } from 'n8n-workflow'; import { Container, Service } from 'typedi'; import { LOWEST_SHUTDOWN_PRIORITY, HIGHEST_SHUTDOWN_PRIORITY } from '@/constants'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; type HandlerFn = () => Promise | void; export type ServiceClass = Class>; 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 418f29c688..5dda04dc18 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 @@ -2,7 +2,7 @@ import type express from 'express'; import { mock } from 'jest-mock-extended'; import type { IdentityProviderInstance, ServiceProviderInstance } from 'samlify'; -import { Logger } from '@/logger'; +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 6705320bee..06a93cc4fb 100644 --- a/packages/cli/src/sso/saml/saml-validator.ts +++ b/packages/cli/src/sso/saml/saml-validator.ts @@ -1,7 +1,7 @@ import { Container } from 'typedi'; import type { XMLFileInfo } from 'xmllint-wasm'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; let xml: XMLFileInfo; let xmldsigCore: XMLFileInfo; diff --git a/packages/cli/src/sso/saml/saml.service.ee.ts b/packages/cli/src/sso/saml/saml.service.ee.ts index f30fa6ff8e..6b07919730 100644 --- a/packages/cli/src/sso/saml/saml.service.ee.ts +++ b/packages/cli/src/sso/saml/saml.service.ee.ts @@ -12,7 +12,7 @@ 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 '@/logger'; +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 f630392280..cf9b122e72 100644 --- a/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts +++ b/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts @@ -5,7 +5,7 @@ import { Service } from 'typedi'; import type { Project } from '@/databases/entities/project'; import { SubworkflowPolicyDenialError } from '@/errors/subworkflow-policy-denial.error'; -import { Logger } from '@/logger'; +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/__tests__/telemetry.test.ts b/packages/cli/src/telemetry/__tests__/telemetry.test.ts index 3851e4523a..407b6437e1 100644 --- a/packages/cli/src/telemetry/__tests__/telemetry.test.ts +++ b/packages/cli/src/telemetry/__tests__/telemetry.test.ts @@ -1,3 +1,4 @@ +import type { GlobalConfig } from '@n8n/config'; import type RudderStack from '@rudderstack/rudder-sdk-node'; import { mock } from 'jest-mock-extended'; import { InstanceSettings } from 'n8n-core'; @@ -41,10 +42,17 @@ describe('Telemetry', () => { beforeEach(async () => { spyTrack.mockClear(); - const postHog = new PostHogClient(instanceSettings); + const postHog = new PostHogClient(instanceSettings, mock()); await postHog.init(); - telemetry = new Telemetry(mock(), postHog, mock(), instanceSettings, mock()); + telemetry = new Telemetry( + mock(), + postHog, + mock(), + instanceSettings, + mock(), + mock({ logging: { level: 'info', outputs: ['console'] } }), + ); // @ts-expect-error Assigning to private property telemetry.rudderStack = mockRudderStack; }); diff --git a/packages/cli/src/telemetry/index.ts b/packages/cli/src/telemetry/index.ts index 8ffca478c1..541429cd36 100644 --- a/packages/cli/src/telemetry/index.ts +++ b/packages/cli/src/telemetry/index.ts @@ -1,3 +1,4 @@ +import { GlobalConfig } from '@n8n/config'; import type RudderStack from '@rudderstack/rudder-sdk-node'; import axios from 'axios'; import { InstanceSettings } from 'n8n-core'; @@ -13,7 +14,7 @@ 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 '@/logger'; +import { Logger } from '@/logging/logger.service'; import { PostHogClient } from '@/posthog'; import { SourceControlPreferencesService } from '../environments/source-control/source-control-preferences.service.ee'; @@ -49,6 +50,7 @@ export class Telemetry { private readonly license: License, private readonly instanceSettings: InstanceSettings, private readonly workflowRepository: WorkflowRepository, + private readonly globalConfig: GlobalConfig, ) {} async init() { @@ -62,7 +64,7 @@ export class Telemetry { return; } - const logLevel = config.getEnv('logs.level'); + const logLevel = this.globalConfig.logging.level; const { default: RudderStack } = await import('@rudderstack/rudder-sdk-node'); const axiosInstance = axios.create(); diff --git a/packages/cli/src/user-management/email/node-mailer.ts b/packages/cli/src/user-management/email/node-mailer.ts index cfc7247546..661c3fed7f 100644 --- a/packages/cli/src/user-management/email/node-mailer.ts +++ b/packages/cli/src/user-management/email/node-mailer.ts @@ -7,7 +7,7 @@ import { createTransport } from 'nodemailer'; import type SMTPConnection from 'nodemailer/lib/smtp-connection'; import { Service } from 'typedi'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import type { MailData, SendEmailResult } from './interfaces'; 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 6703354f07..b5df958d7d 100644 --- a/packages/cli/src/user-management/email/user-management-mailer.ts +++ b/packages/cli/src/user-management/email/user-management-mailer.ts @@ -11,7 +11,7 @@ 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 '@/logger'; +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 7792cf5285..82b42c39df 100644 --- a/packages/cli/src/wait-tracker.ts +++ b/packages/cli/src/wait-tracker.ts @@ -6,7 +6,7 @@ import { import { Service } from 'typedi'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { Logger } from '@/logger'; +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 4c6e0ef7e9..d567fe11b2 100644 --- a/packages/cli/src/webhooks/live-webhooks.ts +++ b/packages/cli/src/webhooks/live-webhooks.ts @@ -6,7 +6,7 @@ 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 '@/logger'; +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 6493fde981..922de9d869 100644 --- a/packages/cli/src/webhooks/waiting-webhooks.ts +++ b/packages/cli/src/webhooks/waiting-webhooks.ts @@ -6,7 +6,7 @@ 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 '@/logger'; +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 c2c3b59bff..5ff770acfb 100644 --- a/packages/cli/src/webhooks/webhook-helpers.ts +++ b/packages/cli/src/webhooks/webhook-helpers.ts @@ -45,7 +45,7 @@ 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 { IExecutionDb, IWorkflowDb } from '@/interfaces'; -import { Logger } from '@/logger'; +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/workflow-execute-additional-data.ts b/packages/cli/src/workflow-execute-additional-data.ts index 96ac4e1b1d..6533f18bb9 100644 --- a/packages/cli/src/workflow-execute-additional-data.ts +++ b/packages/cli/src/workflow-execute-additional-data.ts @@ -63,7 +63,7 @@ import { updateExistingExecution, } from './execution-lifecycle-hooks/shared/shared-hook-functions'; import { toSaveSettings } from './execution-lifecycle-hooks/to-save-settings'; -import { Logger } from './logger'; +import { Logger } from './logging/logger.service'; import { SecretsHelper } from './secrets-helpers'; import { OwnershipService } from './services/ownership.service'; import { UrlService } from './services/url.service'; diff --git a/packages/cli/src/workflow-runner.ts b/packages/cli/src/workflow-runner.ts index a4dd344b62..dd394cbf51 100644 --- a/packages/cli/src/workflow-runner.ts +++ b/packages/cli/src/workflow-runner.ts @@ -26,7 +26,7 @@ import { ActiveExecutions } from '@/active-executions'; import config from '@/config'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { NodeTypes } from '@/node-types'; import type { ScalingService } from '@/scaling/scaling.service'; import type { Job, JobData, JobResult } 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 8b1206b22d..dd8480d759 100644 --- a/packages/cli/src/workflows/workflow-execution.service.ts +++ b/packages/cli/src/workflows/workflow-execution.service.ts @@ -23,7 +23,7 @@ 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 '@/logger'; +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/__tests__/workflow-history.service.ee.test.ts b/packages/cli/src/workflows/workflow-history/__tests__/workflow-history.service.ee.test.ts index 8bc54318bf..cb1b3952ad 100644 --- a/packages/cli/src/workflows/workflow-history/__tests__/workflow-history.service.ee.test.ts +++ b/packages/cli/src/workflows/workflow-history/__tests__/workflow-history.service.ee.test.ts @@ -3,7 +3,7 @@ import { mockClear } from 'jest-mock-extended'; import { User } from '@/databases/entities/user'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { WorkflowHistoryService } from '@/workflows/workflow-history/workflow-history.service.ee'; import { mockInstance } from '@test/mocking'; import { getWorkflow } from '@test-integration/workflow'; 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 7d40c38ec0..eddb8bf7e6 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 @@ -7,7 +7,7 @@ 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 '@/logger'; +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 f639345a1c..10655b77c7 100644 --- a/packages/cli/src/workflows/workflow-static-data.service.ts +++ b/packages/cli/src/workflows/workflow-static-data.service.ts @@ -3,7 +3,7 @@ import { type IDataObject, type Workflow, ErrorReporterProxy as ErrorReporter } import { Service } from 'typedi'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { Logger } from '@/logger'; +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 4e329e7464..90a8af90b1 100644 --- a/packages/cli/src/workflows/workflow.service.ee.ts +++ b/packages/cli/src/workflows/workflow.service.ee.ts @@ -17,7 +17,7 @@ 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 '@/logger'; +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 03ab425a24..bce8770303 100644 --- a/packages/cli/src/workflows/workflow.service.ts +++ b/packages/cli/src/workflows/workflow.service.ts @@ -24,7 +24,7 @@ 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 '@/logger'; +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 30ca5c9773..59f53e0df1 100644 --- a/packages/cli/src/workflows/workflows.controller.ts +++ b/packages/cli/src/workflows/workflows.controller.ts @@ -27,7 +27,7 @@ import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; import type { IWorkflowResponse } from '@/interfaces'; import { License } from '@/license'; -import { Logger } from '@/logger'; +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/pruning.service.test.ts b/packages/cli/test/integration/pruning.service.test.ts index 990d0aec3a..c4d1957de0 100644 --- a/packages/cli/test/integration/pruning.service.test.ts +++ b/packages/cli/test/integration/pruning.service.test.ts @@ -8,7 +8,7 @@ import { TIME } from '@/constants'; import type { ExecutionEntity } from '@/databases/entities/execution-entity'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { PruningService } from '@/services/pruning.service'; import { diff --git a/packages/cli/test/integration/shared/utils/test-server.ts b/packages/cli/test/integration/shared/utils/test-server.ts index c0dcd0ae4c..b69f21499a 100644 --- a/packages/cli/test/integration/shared/utils/test-server.ts +++ b/packages/cli/test/integration/shared/utils/test-server.ts @@ -11,7 +11,7 @@ import { AUTH_COOKIE_NAME } from '@/constants'; import type { User } from '@/databases/entities/user'; import { ControllerRegistry } from '@/decorators'; import { License } from '@/license'; -import { Logger } from '@/logger'; +import { Logger } from '@/logging/logger.service'; import { rawBodyReader, bodyParser } from '@/middlewares'; import { PostHogClient } from '@/posthog'; import { Push } from '@/push'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f11a747188..036ab9af4b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -933,8 +933,8 @@ importers: specifier: 13.7.0 version: 13.7.0 winston: - specifier: 3.8.2 - version: 3.8.2 + specifier: 3.14.2 + version: 3.14.2 ws: specifier: '>=8.17.1' version: 8.17.1 @@ -2726,6 +2726,10 @@ packages: resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} engines: {node: '>=0.1.90'} + '@colors/colors@1.6.0': + resolution: {integrity: sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==} + engines: {node: '>=0.1.90'} + '@common.js/is-network-error@1.0.1': resolution: {integrity: sha512-dkk7FX8L/JLia5pi+IQ11lCw2D6FTmbWL2iWTHgCbP40/deeXgknlkEQcQ/rOkjwQbqp8RZ4ey/anR17K66sqw==} engines: {node: '>=16'} @@ -5510,6 +5514,9 @@ packages: '@types/tough-cookie@4.0.2': resolution: {integrity: sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==} + '@types/triple-beam@1.3.5': + resolution: {integrity: sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==} + '@types/tunnel@0.0.3': resolution: {integrity: sha512-sOUTGn6h1SfQ+gbgqC364jLFBw2lnFqkgF3q0WovEHRLMrVD1sd5aufqi/aJObLekJO+Aq5z646U4Oxy6shXMA==} @@ -9316,8 +9323,9 @@ packages: resolution: {integrity: sha512-9fkkDevMefjg0mmzWFBW8YkFP91OrizzkW3diF7CpG+S2EYdy4+TVfGwz1zeF8x7hCx1ovSPTOE9Ngib74qqUg==} engines: {node: '>=10'} - logform@2.4.2: - resolution: {integrity: sha512-W4c9himeAwXEdZ05dQNerhFz2XG80P9Oj0loPUMV23VC2it0orMHQhJm4hdnnor3rd1HsGf6a2lPwBM1zeXHGw==} + logform@2.6.1: + resolution: {integrity: sha512-CdaO738xRapbKIMVn2m4F6KTj4j7ooJ8POVnebSgKo3KBz5axNXRAL7ZdRjIV6NOr2Uf4vjtRkxrFETOioCqSA==} + engines: {node: '>= 12.0.0'} long@4.0.0: resolution: {integrity: sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==} @@ -12596,12 +12604,12 @@ packages: resolution: {integrity: sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==} engines: {node: '>=8'} - winston-transport@4.5.0: - resolution: {integrity: sha512-YpZzcUzBedhlTAfJg6vJDlyEai/IFMIVcaEZZyl3UXIl4gmqRpU7AE89AHLkbzLUsv0NVmw7ts+iztqKxxPW1Q==} - engines: {node: '>= 6.4.0'} + winston-transport@4.8.0: + resolution: {integrity: sha512-qxSTKswC6llEMZKgCQdaWgDuMJQnhuvF5f2Nk3SNXc4byfQ+voo2mX1Px9dkNOuR8p0KAjfPG29PuYUSIb+vSA==} + engines: {node: '>= 12.0.0'} - winston@3.8.2: - resolution: {integrity: sha512-MsE1gRx1m5jdTTO9Ld/vND4krP2To+lgDoMEHGGa4HIlAUyXJtfc7CxQcGXVyz2IBpw5hbFkj2b/AtUdQwyRew==} + winston@3.14.2: + resolution: {integrity: sha512-CO8cdpBB2yqzEf8v895L+GNKYJiEq8eKlHU38af3snQBQ+sdAIUepjMSguOIJC7ICbzm0ZI+Af2If4vIJrtmOg==} engines: {node: '>= 12.0.0'} with@7.0.2: @@ -13346,7 +13354,7 @@ snapshots: '@aws-crypto/sha256-js': 5.2.0 '@aws-sdk/client-sts': 3.654.0 '@aws-sdk/core': 3.654.0 - '@aws-sdk/credential-provider-node': 3.654.0(@aws-sdk/client-sso-oidc@3.654.0(@aws-sdk/client-sts@3.654.0))(@aws-sdk/client-sts@3.645.0) + '@aws-sdk/credential-provider-node': 3.654.0(@aws-sdk/client-sso-oidc@3.654.0(@aws-sdk/client-sts@3.654.0))(@aws-sdk/client-sts@3.654.0) '@aws-sdk/middleware-host-header': 3.654.0 '@aws-sdk/middleware-logger': 3.654.0 '@aws-sdk/middleware-recursion-detection': 3.654.0 @@ -15035,7 +15043,10 @@ snapshots: style-mod: 4.1.0 w3c-keyname: 2.2.6 - '@colors/colors@1.5.0': {} + '@colors/colors@1.5.0': + optional: true + + '@colors/colors@1.6.0': {} '@common.js/is-network-error@1.0.1': {} @@ -18371,6 +18382,8 @@ snapshots: '@types/tough-cookie@4.0.2': {} + '@types/triple-beam@1.3.5': {} + '@types/tunnel@0.0.3': dependencies: '@types/node': 18.16.16 @@ -19316,7 +19329,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: {} @@ -23119,9 +23132,10 @@ snapshots: slice-ansi: 4.0.0 wrap-ansi: 6.2.0 - logform@2.4.2: + logform@2.6.1: dependencies: - '@colors/colors': 1.5.0 + '@colors/colors': 1.6.0 + '@types/triple-beam': 1.3.5 fecha: 4.2.3 ms: 2.1.3 safe-stable-stringify: 2.4.0 @@ -25626,7 +25640,7 @@ snapshots: simple-lru-cache: 0.0.2 toml: 3.0.0 uuid: 8.3.2 - winston: 3.8.2 + winston: 3.14.2 transitivePeerDependencies: - aws-crt - debug @@ -27007,25 +27021,25 @@ snapshots: dependencies: string-width: 4.2.3 - winston-transport@4.5.0: + winston-transport@4.8.0: dependencies: - logform: 2.4.2 - readable-stream: 3.6.0 + logform: 2.6.1 + readable-stream: 4.5.2 triple-beam: 1.3.0 - winston@3.8.2: + winston@3.14.2: dependencies: - '@colors/colors': 1.5.0 + '@colors/colors': 1.6.0 '@dabh/diagnostics': 2.0.3 async: 3.2.4 is-stream: 2.0.1 - logform: 2.4.2 + logform: 2.6.1 one-time: 1.0.0 readable-stream: 3.6.0 safe-stable-stringify: 2.4.0 stack-trace: 0.0.10 triple-beam: 1.3.0 - winston-transport: 4.5.0 + winston-transport: 4.8.0 with@7.0.2: dependencies: