launchdarkly / node-server-sdk

LaunchDarkly Server-side SDK for Node
Other
79 stars 65 forks source link

Info logs are being written as errors #284

Closed aagranovExtend closed 1 year ago

aagranovExtend commented 1 year ago

Describe the bug Internally calls like this: config.logger.info('Opened LaunchDarkly stream connection');

are turning into errors in our log stream. We're passing a Winston logger to LDDynamoDBOptions.logger.

To reproduce Just initialize the LDClient and use to retrieve feature flag.

Expected behavior That this would only be an info level log.

Logs LD errors

SDK version 7.0.2.

Language version, developer tools TypeScript 4.x

OS/platform AWS

kinyoklion commented 1 year ago

Hello @aagranovExtend,

They are being written to stderr, but are using the info level. This is the info: in the message.

Logging can be customized and you can control the destination as you please. Please see previous issues: https://github.com/launchdarkly/node-server-sdk/issues/251

As noted in that issue you can also simply disable those levels with the basic logger if you prefer that versus controlling the destination.

Lastly this repo has been replaced with: https://github.com/launchdarkly/js-core/tree/main/packages/sdk/server-node

Further development will be done at that location.

Thank you, Ryan

aagranovExtend commented 1 year ago

Hi @kinyoklion I understand the info part, looking at the code: config.logger.info('Initializing stream processor to receive feature flag updates');

I'm not sure what you mean by this being written to stderr, and how me configuring the Winston logger differently would affect that?

kinyoklion commented 1 year ago

So, we are just using console.error in the default logger. Which the default behavior in node is just to log to stderr. (Application output generally going to stdout or stderr.)

So either winston is intercepting that and directing it someplace, or the default handling is being used.

As I discussed in the other issue you can control this directly.

const options = {
  logger: {
    error:  (...args) => console.error(...args),
    warn:  (...args) =>  console.warn(...args),
    info:  (...args) => console.info(...args),
    debug:  (...args) => console.error(...args),
  }
}

If you want to do something winston specific, then you could replace the console. calls with whatever winston logger at whatever winston logger level, you want.

Thank you, Ryan