Better logs
This commit is contained in:
@@ -25,25 +25,24 @@ export const deliverQueue = initializeQueue('deliver');
|
||||
export const inboxQueue = initializeQueue('inbox');
|
||||
export const dbQueue = initializeQueue('db');
|
||||
|
||||
const deliverLogger = queueLogger.createSubLogger('deliver');
|
||||
const inboxLogger = queueLogger.createSubLogger('inbox');
|
||||
|
||||
deliverQueue
|
||||
.on('waiting', (jobId) => {
|
||||
queueLogger.debug(`[deliver] waiting id=${jobId}`);
|
||||
})
|
||||
.on('active', (job) => {
|
||||
queueLogger.debug(`[deliver] active id=${job.id} to=${job.data.to}`);
|
||||
})
|
||||
.on('completed', (job, result) => {
|
||||
queueLogger.debug(`[deliver] completed(${result}) id=${job.id} to=${job.data.to}`);
|
||||
})
|
||||
.on('failed', (job, err) => {
|
||||
queueLogger.debug(`[deliver] failed(${err}) id=${job.id} to=${job.data.to}`);
|
||||
})
|
||||
.on('error', (error) => {
|
||||
queueLogger.error(`[deliver] error ${error}`);
|
||||
})
|
||||
.on('stalled', (job) => {
|
||||
queueLogger.warn(`[deliver] stalled id=${job.id} to=${job.data.to}`);
|
||||
});
|
||||
.on('waiting', (jobId) => deliverLogger.debug(`waiting id=${jobId}`))
|
||||
.on('active', (job) => deliverLogger.debug(`active id=${job.id} to=${job.data.to}`))
|
||||
.on('completed', (job, result) => deliverLogger.debug(`completed(${result}) id=${job.id} to=${job.data.to}`))
|
||||
.on('failed', (job, err) => deliverLogger.debug(`failed(${err}) id=${job.id} to=${job.data.to}`))
|
||||
.on('error', (error) => deliverLogger.error(`error ${error}`))
|
||||
.on('stalled', (job) => deliverLogger.warn(`stalled id=${job.id} to=${job.data.to}`));
|
||||
|
||||
inboxQueue
|
||||
.on('waiting', (jobId) => inboxLogger.debug(`waiting id=${jobId}`))
|
||||
.on('active', (job) => inboxLogger.debug(`active id=${job.id} to=${job.data.to}`))
|
||||
.on('completed', (job, result) => inboxLogger.debug(`completed(${result}) id=${job.id} to=${job.data.to}`))
|
||||
.on('failed', (job, err) => inboxLogger.debug(`failed(${err}) id=${job.id} to=${job.data.to}`))
|
||||
.on('error', (error) => inboxLogger.error(`error ${error}`))
|
||||
.on('stalled', (job) => inboxLogger.warn(`stalled id=${job.id} to=${job.data.to}`));
|
||||
|
||||
export function deliver(user: ILocalUser, content: any, to: any) {
|
||||
if (content == null) return null;
|
||||
@@ -146,12 +145,12 @@ export default function() {
|
||||
|
||||
export function destroy() {
|
||||
deliverQueue.once('cleaned', (jobs, status) => {
|
||||
queueLogger.succ(`[deliver] Cleaned ${jobs.length} ${status} jobs`);
|
||||
deliverLogger.succ(`Cleaned ${jobs.length} ${status} jobs`);
|
||||
});
|
||||
deliverQueue.clean(0, 'wait');
|
||||
|
||||
inboxQueue.once('cleaned', (jobs, status) => {
|
||||
queueLogger.succ(`[inbox] Cleaned ${jobs.length} ${status} jobs`);
|
||||
inboxLogger.succ(`Cleaned ${jobs.length} ${status} jobs`);
|
||||
});
|
||||
inboxQueue.clean(0, 'wait');
|
||||
}
|
||||
|
Reference in New Issue
Block a user