From 942030610ab1e9d2e8a93310734cba25f12bf8bb Mon Sep 17 00:00:00 2001 From: Roberto Sebestyen Date: Thu, 22 Oct 2020 18:47:27 -0400 Subject: [PATCH] add CONSOLE_LOG_JSON_NO_LOGGER_DEBUG strip option --- README.md | 10 ++++++---- src/logger.ts | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b9bc579..4140e07 100644 --- a/README.md +++ b/README.md @@ -44,14 +44,16 @@ so that it can be easily parsed by tool such as LogDNA. To suppress some bits of the log to make it less noisy you can set these environment variables: -* CONSOLE_LOG_JSON_NO_FILE_NAME = 'true' +* CONSOLE_LOG_JSON_NO_FILE_NAME="true" * Omits `@filename` in log -* CONSOLE_LOG_JSON_NO_PACKAGE_NAME = 'true' +* CONSOLE_LOG_JSON_NO_PACKAGE_NAME="true" * Omits `@packageName` in log -* CONSOLE_LOG_JSON_NO_TIME_STAMP = 'true' +* CONSOLE_LOG_JSON_NO_TIME_STAMP="true" * Omits `@timestamp` in log -* CONSOLE_LOG_JSON_NO_STACK_FOR_NON_ERROR = 'true' +* CONSOLE_LOG_JSON_NO_STACK_FOR_NON_ERROR="true" * Omits `@logCallStack` in log +* CONSOLE_LOG_JSON_NO_LOGGER_DEBUG="true" + * Omits `_loggerDebug` in log ## Examples diff --git a/src/logger.ts b/src/logger.ts index f2b1704..83b6c3e 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -427,6 +427,7 @@ function supressDetailsIfSelected(errorObject: ErrorWithContext | undefined) { const { CONSOLE_LOG_JSON_NO_STACK_FOR_NON_ERROR } = process.env; const { CONSOLE_LOG_JSON_NO_FILE_NAME } = process.env; const { CONSOLE_LOG_JSON_NO_PACKAGE_NAME } = process.env; + const { CONSOLE_LOG_JSON_NO_LOGGER_DEBUG } = process.env; if (errorObject == undefined) { return undefined; @@ -444,6 +445,10 @@ function supressDetailsIfSelected(errorObject: ErrorWithContext | undefined) { delete (errorObject as any)['@packageName']; } + if (CONSOLE_LOG_JSON_NO_LOGGER_DEBUG?.toLowerCase() === 'true') { + delete (errorObject as any)._loggerDebug; + } + return errorObject; }