snowflakedb / snowflake-connector-nodejs

NodeJS driver
Apache License 2.0
124 stars 132 forks source link

SNOW-1800528: Disabling logging without anything being logged to stdout is difficult #957

Open visnup opened 4 days ago

visnup commented 4 days ago

Please answer these questions before submitting your issue. In order to accurately debug the issue this information is required. Thanks!

  1. What version of NodeJS driver are you using? 1.15.0

  2. What operating system and processor architecture are you using? darwin arm64

  3. What version of NodeJS are you using? v20.18.0

  4. What are the component versions in the environment (npm list)? N/A

  5. What did you do?

snowflake.configure({logLevel: "OFF"});
  1. What did you expect to see?

No logging to stdout anywhere. Instead, I see the message

{"level":"INFO","message":"[2:27:54.321 PM]: Configuring logger with level: -1, filePath: undefined, additionalLogToConsole: undefined"}

logged to console/stdout before it finally turns off. This seems to defeat the purpose of silencing logging to stdout. This is important to me because the output to my program (querying Snowflake) is used as input to another process, and the downstream process is confused by seeing Snowflake logging output.

As a workaround, I've instead done

import Logger from "snowflake-sdk/lib/logger.js";
Logger.getInstance().configure({level: -1});

but this isn't documented anywhere. Other workarounds like setting additionalLogToConsole to false doesn't work because a log file isn't set, and setting logFilePath also triggers that initial, unwanted message: https://github.com/snowflakedb/snowflake-connector-nodejs/blob/d50e1ce273ef945cd82ecd0a9480546134efe55b/lib/core.js#L189-L190

sfc-gh-dszmolka commented 4 days ago

hi - you're right, that's not how OFF loglevel intended to work. we'll take a look.

sfc-gh-dszmolka commented 4 days ago

PR https://github.com/snowflakedb/snowflake-connector-nodejs/pull/958 edit: merged, will be part of the next upcoming release cycle