From 6b051b260e8c17cd6193b0a6d1b9c601a05437cb Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 24 Aug 2023 13:26:10 +0200 Subject: [PATCH] Merge pull request #14296 from overleaf/jpa-error-serializer [logger] serialize "error" field with customer error serializer GitOrigin-RevId: 1cb588e84798c96286aec8f7f054570270a36b72 --- libraries/logger/gcp-manager.js | 25 ++++++++++++++----------- libraries/logger/logging-manager.js | 1 + 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/libraries/logger/gcp-manager.js b/libraries/logger/gcp-manager.js index 6e0f07e82a..99fe6d4f4e 100644 --- a/libraries/logger/gcp-manager.js +++ b/libraries/logger/gcp-manager.js @@ -13,6 +13,7 @@ const ENTRY_FIELDS_TO_OMIT = [ 'pid', 'msg', 'err', + 'error', 'req', 'res', ] @@ -25,20 +26,22 @@ function convertLogEntry(entry) { // Error information. In GCP, the stack trace goes in the message property. // This enables the error reporting feature. - if (entry.err) { - if (entry.err.info) { - Object.assign(gcpEntry, entry.err.info) + const err = entry.err || entry.error + if (err) { + if (err.info) { + Object.assign(gcpEntry, err.info) } - if (entry.err.code) { - gcpEntry.code = entry.err.code + if (err.code) { + gcpEntry.code = err.code } - if (entry.err.signal) { - gcpEntry.signal = entry.err.signal + if (err.signal) { + gcpEntry.signal = err.signal } - if (entry.err.stack !== '(no stack)') { - gcpEntry.message = entry.err.stack - } else if (entry.err.message) { - gcpEntry.message = entry.err.message + const stack = err.stack + if (stack && stack !== '(no stack)') { + gcpEntry.message = stack + } else if (err.message) { + gcpEntry.message = err.message } if (entry.name) { gcpEntry.serviceContext = { service: entry.name } diff --git a/libraries/logger/logging-manager.js b/libraries/logger/logging-manager.js index 6c2d7502a5..6a59b242e9 100644 --- a/libraries/logger/logging-manager.js +++ b/libraries/logger/logging-manager.js @@ -19,6 +19,7 @@ const LoggingManager = { name, serializers: { err: Serializers.err, + error: Serializers.err, req: Serializers.req, res: Serializers.res, },