@lokalise/background-jobs-common
Advanced tools
Comparing version 7.2.0 to 7.3.0
@@ -22,3 +22,5 @@ import type { BackgroundJobProcessorConfig, BackgroundJobProcessorDependencies } from '../processors/types'; | ||
jobStart(job: JobType, requestContext: RequestContext): void; | ||
jobAttemptError(job: JobType, error: unknown, requestContext: RequestContext): void; | ||
jobEnd(job: JobType, requestContext: RequestContext): void; | ||
private buildLogParams; | ||
} |
@@ -5,2 +5,3 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const node_core_1 = require("@lokalise/node-core"); | ||
const ioredis_1 = tslib_1.__importDefault(require("ioredis")); | ||
@@ -65,7 +66,10 @@ const constants_1 = require("../constants"); | ||
this.transactionObservabilityManager.start(transactionName, (0, utils_1.resolveJobId)(job)); | ||
requestContext.logger.info({ origin: this.processorName }, `Started job ${job.name}`); | ||
requestContext.logger.info(this.buildLogParams(job), `Started job ${job.name}`); | ||
} | ||
jobAttemptError(job, error, requestContext) { | ||
requestContext.logger.error(this.buildLogParams(job, error), `${job.name} try failed`); | ||
} | ||
jobEnd(job, requestContext) { | ||
requestContext.logger.info({ | ||
origin: this.processorName, | ||
...this.buildLogParams(job), | ||
isSuccess: job.progress === 100, | ||
@@ -75,2 +79,9 @@ }, `Finished job ${job.name}`); | ||
} | ||
buildLogParams(job, error) { | ||
return { | ||
origin: this.processorName, | ||
jobProgress: job.progress, | ||
...(error ? (0, node_core_1.resolveGlobalErrorLogObject)(error) : {}), | ||
}; | ||
} | ||
} | ||
@@ -77,0 +88,0 @@ exports.BackgroundJobProcessorMonitor = BackgroundJobProcessorMonitor; |
@@ -192,2 +192,6 @@ "use strict"; | ||
} | ||
catch (error) { | ||
this.monitor.jobAttemptError(job, error, requestContext); | ||
throw error; | ||
} | ||
finally { | ||
@@ -194,0 +198,0 @@ this.monitor.jobEnd(job, requestContext); |
{ | ||
"name": "@lokalise/background-jobs-common", | ||
"version": "7.2.0", | ||
"version": "7.3.0", | ||
"files": ["dist", "LICENSE.md", "README.md"], | ||
@@ -5,0 +5,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69847
1363