From 158a134eca12596bc36b3a0fc61b56064da79d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luismi=20Ram=C3=ADrez?= Date: Tue, 30 Nov 2021 11:26:26 +0100 Subject: [PATCH] Add logLevel config option This new option allows users to set up the level of severity AppSignal logs. --- .../.changesets/add-loglevel-config-option.md | 14 ++++++++++++++ ...ebug-and-transactiondebugmode-config-options.md | 7 +++++++ packages/nodejs/src/__tests__/config.test.ts | 4 ++++ packages/nodejs/src/config.ts | 1 + packages/nodejs/src/config/configmap.ts | 3 +++ test/integration/diagnose | 2 +- 6 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 packages/nodejs/.changesets/add-loglevel-config-option.md create mode 100644 packages/nodejs/.changesets/deprecate-debug-and-transactiondebugmode-config-options.md diff --git a/packages/nodejs/.changesets/add-loglevel-config-option.md b/packages/nodejs/.changesets/add-loglevel-config-option.md new file mode 100644 index 00000000..15be4ae3 --- /dev/null +++ b/packages/nodejs/.changesets/add-loglevel-config-option.md @@ -0,0 +1,14 @@ +--- +bump: "patch" +type: "add" +--- + +Add "logLevel" config option. This new option allows you to select the type of messages +AppSignal's logger will log and up. The "debug" option will log all "debug", "info", "warning" +and "error" log messages. The default value is: "info" + +The allowed values are: +- error +- warning +- info +- debug diff --git a/packages/nodejs/.changesets/deprecate-debug-and-transactiondebugmode-config-options.md b/packages/nodejs/.changesets/deprecate-debug-and-transactiondebugmode-config-options.md new file mode 100644 index 00000000..a094aad9 --- /dev/null +++ b/packages/nodejs/.changesets/deprecate-debug-and-transactiondebugmode-config-options.md @@ -0,0 +1,7 @@ +--- +bump: "patch" +type: "deprecate" +--- + +Deprecate "debug" and "transactionDebugMode" config options in favor of the new "logLevel" +config option. diff --git a/packages/nodejs/src/__tests__/config.test.ts b/packages/nodejs/src/__tests__/config.test.ts index 5329cf40..da3d8901 100644 --- a/packages/nodejs/src/__tests__/config.test.ts +++ b/packages/nodejs/src/__tests__/config.test.ts @@ -28,6 +28,7 @@ describe("Configuration", () => { ignoreErrors: [], ignoreNamespaces: [], log: "file", + logLevel: "info", requestHeaders: [ "accept", "accept-charset", @@ -265,6 +266,7 @@ describe("Configuration", () => { expect(env("_APPSIGNAL_IGNORE_ERRORS")).toBeUndefined() expect(env("_APPSIGNAL_IGNORE_NAMESPACES")).toBeUndefined() expect(env("_APPSIGNAL_LOG")).toEqual("file") + expect(env("_APPSIGNAL_LOG_LEVEL")).toEqual("info") expect(env("_APPSIGNAL_LOG_FILE_PATH")).toEqual("/tmp/appsignal.log") expect(env("_APPSIGNAL_PUSH_API_ENDPOINT")).toEqual( "https://push.appsignal.com" @@ -305,6 +307,7 @@ describe("Configuration", () => { ignoreActions: ["MyAction", "MyOtherAction"], ignoreErrors: ["MyError", "MyOtherError"], ignoreNamespaces: ["MyNamespace", "MyOtherNamespace"], + logLevel: "debug", logPath: "/tmp/other", runningInContainer: true, workingDirectoryPath: "/my/path", @@ -334,6 +337,7 @@ describe("Configuration", () => { "MyNamespace,MyOtherNamespace" ) expect(env("_APPSIGNAL_LOG")).toEqual("file") + expect(env("_APPSIGNAL_LOG_LEVEL")).toEqual("debug") expect(env("_APPSIGNAL_LOG_FILE_PATH")).toEqual( path.join("/tmp/other", "appsignal.log") ) diff --git a/packages/nodejs/src/config.ts b/packages/nodejs/src/config.ts index fbb0dcae..16045f55 100644 --- a/packages/nodejs/src/config.ts +++ b/packages/nodejs/src/config.ts @@ -128,6 +128,7 @@ export class Configuration { ignoreErrors: [], ignoreNamespaces: [], log: "file", + logLevel: "info", requestHeaders: [ "accept", "accept-charset", diff --git a/packages/nodejs/src/config/configmap.ts b/packages/nodejs/src/config/configmap.ts index 5e81ecfa..e0ccdc90 100644 --- a/packages/nodejs/src/config/configmap.ts +++ b/packages/nodejs/src/config/configmap.ts @@ -18,6 +18,7 @@ export const ENV_TO_KEY_MAPPING: { [key: string]: string } = { APPSIGNAL_IGNORE_ERRORS: "ignoreErrors", APPSIGNAL_IGNORE_NAMESPACES: "ignoreNamespaces", APPSIGNAL_LOG: "log", + APPSIGNAL_LOG_LEVEL: "logLevel", APPSIGNAL_LOG_PATH: "logPath", APPSIGNAL_PUSH_API_ENDPOINT: "endpoint", APPSIGNAL_PUSH_API_KEY: "pushApiKey", @@ -50,6 +51,7 @@ export const PRIVATE_ENV_MAPPING: { [key: string]: string } = { _APPSIGNAL_IGNORE_ERRORS: "ignoreErrors", _APPSIGNAL_IGNORE_NAMESPACES: "ignoreNamespaces", _APPSIGNAL_LOG: "log", + _APPSIGNAL_LOG_LEVEL: "logLevel", _APPSIGNAL_PUSH_API_ENDPOINT: "endpoint", _APPSIGNAL_PUSH_API_KEY: "pushApiKey", _APPSIGNAL_RUNNING_IN_CONTAINER: "runningInContainer", @@ -79,6 +81,7 @@ export const JS_TO_RUBY_MAPPING: { [key: string]: string } = { ignoreErrors: "ignore_errors", ignoreNamespaces: "ignore_namespaces", log: "log", + logLevel: "log_level", logPath: "log_path", name: "name", requestHeaders: "request_headers", diff --git a/test/integration/diagnose b/test/integration/diagnose index d1fdc28a..3718ed6a 160000 --- a/test/integration/diagnose +++ b/test/integration/diagnose @@ -1 +1 @@ -Subproject commit d1fdc28af6f4f478e411f32519d69e27dff801c8 +Subproject commit 3718ed6a907c475634a277e193c45e7aaba48fa4