mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Make Logger a service (no-changelog) (#7494)
This commit is contained in:
committed by
GitHub
parent
db4e61ba24
commit
05586a900d
@@ -13,7 +13,7 @@ import type {
|
||||
INodeTypes,
|
||||
IRun,
|
||||
} from 'n8n-workflow';
|
||||
import { Workflow, NodeOperationError, LoggerProxy, sleep } from 'n8n-workflow';
|
||||
import { Workflow, NodeOperationError, sleep } from 'n8n-workflow';
|
||||
|
||||
import * as Db from '@/Db';
|
||||
import * as ResponseHelper from '@/ResponseHelper';
|
||||
@@ -71,7 +71,7 @@ export class Worker extends BaseCommand {
|
||||
* get removed.
|
||||
*/
|
||||
async stopProcess() {
|
||||
LoggerProxy.info('Stopping n8n...');
|
||||
this.logger.info('Stopping n8n...');
|
||||
|
||||
// Stop accepting new jobs
|
||||
await Worker.jobQueue.pause(true);
|
||||
@@ -94,7 +94,7 @@ export class Worker extends BaseCommand {
|
||||
while (Object.keys(Worker.runningJobs).length !== 0) {
|
||||
if (count++ % 4 === 0) {
|
||||
const waitLeft = Math.ceil((stopTime - new Date().getTime()) / 1000);
|
||||
LoggerProxy.info(
|
||||
this.logger.info(
|
||||
`Waiting for ${
|
||||
Object.keys(Worker.runningJobs).length
|
||||
} active executions to finish... (wait ${waitLeft} more seconds)`,
|
||||
@@ -121,7 +121,7 @@ export class Worker extends BaseCommand {
|
||||
);
|
||||
|
||||
if (!fullExecutionData) {
|
||||
LoggerProxy.error(
|
||||
this.logger.error(
|
||||
`Worker failed to find data of execution "${executionId}" in database. Cannot continue.`,
|
||||
{ executionId },
|
||||
);
|
||||
@@ -130,7 +130,7 @@ export class Worker extends BaseCommand {
|
||||
);
|
||||
}
|
||||
const workflowId = fullExecutionData.workflowData.id!;
|
||||
LoggerProxy.info(
|
||||
this.logger.info(
|
||||
`Start job: ${job.id} (Workflow ID: ${workflowId} | Execution: ${executionId})`,
|
||||
);
|
||||
|
||||
@@ -145,7 +145,7 @@ export class Worker extends BaseCommand {
|
||||
},
|
||||
});
|
||||
if (workflowData === null) {
|
||||
LoggerProxy.error(
|
||||
this.logger.error(
|
||||
'Worker execution failed because workflow could not be found in database.',
|
||||
{ workflowId, executionId },
|
||||
);
|
||||
@@ -217,7 +217,7 @@ export class Worker extends BaseCommand {
|
||||
|
||||
additionalData.setExecutionStatus = (status: ExecutionStatus) => {
|
||||
// Can't set the status directly in the queued worker, but it will happen in InternalHook.onWorkflowPostExecute
|
||||
LoggerProxy.debug(`Queued worker execution status for ${executionId} is "${status}"`);
|
||||
this.logger.debug(`Queued worker execution status for ${executionId} is "${status}"`);
|
||||
};
|
||||
|
||||
let workflowExecute: WorkflowExecute;
|
||||
@@ -400,7 +400,7 @@ export class Worker extends BaseCommand {
|
||||
'/healthz',
|
||||
|
||||
async (req: express.Request, res: express.Response) => {
|
||||
LoggerProxy.debug('Health check started!');
|
||||
this.logger.debug('Health check started!');
|
||||
|
||||
const connection = Db.getConnection();
|
||||
|
||||
@@ -412,7 +412,7 @@ export class Worker extends BaseCommand {
|
||||
// DB ping
|
||||
await connection.query('SELECT 1');
|
||||
} catch (e) {
|
||||
LoggerProxy.error('No Database connection!', e as Error);
|
||||
this.logger.error('No Database connection!', e as Error);
|
||||
const error = new ResponseHelper.ServiceUnavailableError('No Database connection!');
|
||||
return ResponseHelper.sendErrorResponse(res, error);
|
||||
}
|
||||
@@ -423,7 +423,7 @@ export class Worker extends BaseCommand {
|
||||
// Redis ping
|
||||
await Worker.jobQueue.ping();
|
||||
} catch (e) {
|
||||
LoggerProxy.error('No Redis connection!', e as Error);
|
||||
this.logger.error('No Redis connection!', e as Error);
|
||||
const error = new ResponseHelper.ServiceUnavailableError('No Redis connection!');
|
||||
return ResponseHelper.sendErrorResponse(res, error);
|
||||
}
|
||||
@@ -433,7 +433,7 @@ export class Worker extends BaseCommand {
|
||||
status: 'ok',
|
||||
};
|
||||
|
||||
LoggerProxy.debug('Health check completed successfully!');
|
||||
this.logger.debug('Health check completed successfully!');
|
||||
|
||||
ResponseHelper.sendSuccessResponse(res, responseData, true, 200);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user