From d8a7e99c811468d4b0373784d406d1a035121b34 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Wed, 3 Aug 2022 09:23:29 -0700 Subject: [PATCH] Consistent log lines for WebAPI requests --- ts/textsecure/WebAPI.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ts/textsecure/WebAPI.ts b/ts/textsecure/WebAPI.ts index f0d091aa3..5fe81988c 100644 --- a/ts/textsecure/WebAPI.ts +++ b/ts/textsecure/WebAPI.ts @@ -239,7 +239,8 @@ async function _promiseAjax( const redactedURL = options.redactUrl ? options.redactUrl(url) : url; const unauthLabel = options.unauthenticated ? ' (unauth)' : ''; - log.info(`${options.type} ${logType} ${redactedURL}${unauthLabel}`); + const logId = `${options.type} ${logType} ${redactedURL}${unauthLabel}`; + log.info(logId); const timeout = typeof options.timeout === 'number' ? options.timeout : 10000; @@ -343,13 +344,13 @@ async function _promiseAjax( result = await response.textConverted(); } } catch (e) { - log.error(options.type, logType, redactedURL, 0, 'Error'); + log.error(logId, 0, 'Error'); const stack = `${e.stack}\nInitial stack:\n${options.stack}`; throw makeHTTPError('promiseAjax catch', 0, {}, e.toString(), stack); } if (!isSuccess(response.status)) { - log.error(options.type, logType, redactedURL, response.status, 'Error'); + log.error(logId, response.status, 'Error'); throw makeHTTPError( 'promiseAjax: error response', @@ -366,7 +367,7 @@ async function _promiseAjax( ) { if (options.validateResponse) { if (!_validateResponse(result, options.validateResponse)) { - log.error(options.type, logType, redactedURL, response.status, 'Error'); + log.error(logId, response.status, 'Error'); throw makeHTTPError( 'promiseAjax: invalid response', response.status, @@ -378,7 +379,7 @@ async function _promiseAjax( } } - log.info(options.type, logType, redactedURL, response.status, 'Success'); + log.info(logId, response.status, 'Success'); if (options.responseType === 'byteswithdetails') { assert(result instanceof Uint8Array, 'Expected Uint8Array result');