From ad0997adfb9e1e3b1ff54338d7558cf7b18440ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 7 Jul 2017 18:26:12 +0200 Subject: Fix error logging --- server/lib/friends.ts | 6 +++--- server/lib/jobs/handlers/video-transcoder.ts | 2 +- server/lib/jobs/job-scheduler.ts | 10 +++++----- server/lib/request/abstract-request-scheduler.ts | 4 ++-- server/lib/request/request-scheduler.ts | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'server/lib') diff --git a/server/lib/friends.ts b/server/lib/friends.ts index c24839cb6..3487addbe 100644 --- a/server/lib/friends.ts +++ b/server/lib/friends.ts @@ -180,7 +180,7 @@ function quitFriends () { }, { concurrency: REQUESTS_IN_PARALLEL }) .then(() => pods) .catch(err => { - logger.error('Some errors while quitting friends.', { err: err }) + logger.error('Some errors while quitting friends.', err) // Don't stop the process }) }) @@ -215,7 +215,7 @@ function sendOwnedVideosToPod (podId: number) { return createRequest(options) }) .catch(err => { - logger.error('Cannot convert video to remote.', { error: err }) + logger.error('Cannot convert video to remote.', err) // Don't break the process return undefined }) @@ -344,7 +344,7 @@ function makeRequestsToWinningPods (cert: string, podsList: PodInstance[]) { sendOwnedVideosToPod(podCreated.id) }) .catch(err => { - logger.error('Cannot add friend %s pod.', pod.host, { error: err }) + logger.error('Cannot add friend %s pod.', pod.host, err) }) } else { logger.error('Status not 200 for %s pod.', pod.host) diff --git a/server/lib/jobs/handlers/video-transcoder.ts b/server/lib/jobs/handlers/video-transcoder.ts index e829ca813..eeb2d57b0 100644 --- a/server/lib/jobs/handlers/video-transcoder.ts +++ b/server/lib/jobs/handlers/video-transcoder.ts @@ -10,7 +10,7 @@ function process (data: { id: string }) { } function onError (err: Error, jobId: number) { - logger.error('Error when transcoding video file in job %d.', jobId, { error: err }) + logger.error('Error when transcoding video file in job %d.', jobId, err) return Promise.resolve() } diff --git a/server/lib/jobs/job-scheduler.ts b/server/lib/jobs/job-scheduler.ts index 248dc7978..2ae732b0f 100644 --- a/server/lib/jobs/job-scheduler.ts +++ b/server/lib/jobs/job-scheduler.ts @@ -51,13 +51,13 @@ class JobScheduler { // Optimization: we could use "drain" from queue object return setTimeout(next, JOBS_FETCHING_INTERVAL) }) - .catch(err => logger.error('Cannot list pending jobs.', { error: err })) + .catch(err => logger.error('Cannot list pending jobs.', err)) }, - err => logger.error('Error in job scheduler queue.', { error: err }) + err => logger.error('Error in job scheduler queue.', err) ) }) - .catch(err => logger.error('Cannot list pending jobs.', { error: err })) + .catch(err => logger.error('Cannot list pending jobs.', err)) } createJob (transaction: Sequelize.Transaction, handlerName: string, handlerInputData: object) { @@ -95,7 +95,7 @@ class JobScheduler { }, err => { - logger.error('Error in job handler %s.', job.handlerName, { error: err }) + logger.error('Error in job handler %s.', job.handlerName, err) return this.onJobError(jobHandler, job, err) } ) @@ -123,7 +123,7 @@ class JobScheduler { } private cannotSaveJobError (err: Error) { - logger.error('Cannot save new job state.', { error: err }) + logger.error('Cannot save new job state.', err) } } diff --git a/server/lib/request/abstract-request-scheduler.ts b/server/lib/request/abstract-request-scheduler.ts index 128fc5b28..0a9ff65d5 100644 --- a/server/lib/request/abstract-request-scheduler.ts +++ b/server/lib/request/abstract-request-scheduler.ts @@ -84,7 +84,7 @@ abstract class AbstractRequestScheduler { } }) .catch(err => { - logger.error('Error sending secure request to %s pod.', toPod.host, { error: err }) + logger.error('Error sending secure request to %s pod.', toPod.host, err) throw err }) @@ -124,7 +124,7 @@ abstract class AbstractRequestScheduler { }) .catch(err => { badPods.push(requestToMake.toPod.id) - logger.info('Cannot make request to %s.', toPod.host, { error: err }) + logger.info('Cannot make request to %s.', toPod.host, err) }) }, { concurrency: REQUESTS_IN_PARALLEL }).then(() => ({ goodPods, badPods })) }) diff --git a/server/lib/request/request-scheduler.ts b/server/lib/request/request-scheduler.ts index 8927d53bb..3945ace20 100644 --- a/server/lib/request/request-scheduler.ts +++ b/server/lib/request/request-scheduler.ts @@ -87,7 +87,7 @@ class RequestScheduler extends AbstractRequestScheduler { afterRequestsHook () { // Flush requests with no pod this.getRequestModel().removeWithEmptyTo() - .catch(err => logger.error('Error when removing requests with no pods.', { error: err })) + .catch(err => logger.error('Error when removing requests with no pods.', err)) } } -- cgit v1.2.3