force one-line log (queue processor)

This commit is contained in:
tamaina 2024-03-04 12:07:03 +00:00
parent 84a6877f57
commit d84a5767bf

View file

@ -68,6 +68,25 @@ function getJobInfo(job: Bull.Job | undefined, increment = false): string {
return `id=${job.id} attempts=${currentAttempts}/${maxAttempts} age=${formated}`; return `id=${job.id} attempts=${currentAttempts}/${maxAttempts} age=${formated}`;
} }
function renderError(e: Error): any {
if (e) { // 何故かeがundefinedで来ることがある
return {
...Object.getOwnPropertyNames(e).reduce((acc, key) => {
//@ts-expect-error Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Error'.
acc[key] = e[key];
return acc;
}, {} as Record<string, any>),
stack: e.stack?.split('\n').map(s => s.trim()),
};
} else {
return {
stack: '?',
message: '?',
name: '?',
};
}
}
@Injectable() @Injectable()
export class QueueProcessorService implements OnApplicationShutdown { export class QueueProcessorService implements OnApplicationShutdown {
private logger: Logger; private logger: Logger;
@ -118,18 +137,6 @@ export class QueueProcessorService implements OnApplicationShutdown {
) { ) {
this.logger = this.queueLoggerService.logger; this.logger = this.queueLoggerService.logger;
function renderError(e: Error): any {
if (e) { // 何故かeがundefinedで来ることがある
return e;
} else {
return {
stack: '?',
message: '?',
name: '?',
};
}
}
//#region system //#region system
this.systemQueueWorker = new Bull.Worker(QUEUE.SYSTEM, (job) => { this.systemQueueWorker = new Bull.Worker(QUEUE.SYSTEM, (job) => {
switch (job.name) { switch (job.name) {