refactor(core): Make Logger a service (no-changelog) (#7494)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-10-25 16:35:22 +02:00
committed by GitHub
parent db4e61ba24
commit 05586a900d
131 changed files with 761 additions and 919 deletions

View File

@@ -17,7 +17,6 @@ import type {
SelectQueryBuilder,
} from 'typeorm';
import { parse, stringify } from 'flatted';
import { LoggerProxy as Logger } from 'n8n-workflow';
import type { IExecutionsSummary, IRunExecutionData } from 'n8n-workflow';
import { BinaryDataService } from 'n8n-core';
import type {
@@ -35,6 +34,7 @@ import { ExecutionEntity } from '../entities/ExecutionEntity';
import { ExecutionMetadata } from '../entities/ExecutionMetadata';
import { ExecutionDataRepository } from './executionData.repository';
import { TIME, inTest } from '@/constants';
import { Logger } from '@/Logger';
function parseFiltersToQueryBuilder(
qb: SelectQueryBuilder<ExecutionEntity>,
@@ -77,8 +77,6 @@ function parseFiltersToQueryBuilder(
@Service()
export class ExecutionRepository extends Repository<ExecutionEntity> {
private logger = Logger;
private hardDeletionBatchSize = 100;
private rates: Record<string, number> = {
@@ -96,6 +94,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
constructor(
dataSource: DataSource,
private readonly logger: Logger,
private readonly executionDataRepository: ExecutionDataRepository,
private readonly binaryDataService: BinaryDataService,
) {
@@ -360,7 +359,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
}
} catch (error) {
if (error instanceof Error) {
Logger.warn(`Failed to get executions count from Postgres: ${error.message}`, {
this.logger.warn(`Failed to get executions count from Postgres: ${error.message}`, {
error,
});
}
@@ -461,7 +460,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
if (!executions.length) {
if (deleteConditions.ids) {
Logger.error('Failed to delete an execution due to insufficient permissions', {
this.logger.error('Failed to delete an execution due to insufficient permissions', {
executionIds: deleteConditions.ids,
});
}
@@ -480,7 +479,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
* Mark executions as deleted based on age and count, in a pruning cycle.
*/
async softDeleteOnPruningCycle() {
Logger.debug('Starting soft-deletion of executions (pruning cycle)');
this.logger.debug('Starting soft-deletion of executions (pruning cycle)');
const maxAge = config.getEnv('executions.pruneDataMaxAge'); // in h
const maxCount = config.getEnv('executions.pruneDataMaxCount');
@@ -527,7 +526,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
.execute();
if (result.affected === 0) {
Logger.debug('Found no executions to soft-delete (pruning cycle)');
this.logger.debug('Found no executions to soft-delete (pruning cycle)');
}
}