launchdarkly / node-server-sdk

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

Stop logging when feature flag not found #261

Closed edxzh closed 2 years ago

edxzh commented 2 years ago

Is your feature request related to a problem? Please describe. no

Describe the solution you'd like get ride of https://github.com/launchdarkly/node-server-sdk/blob/main/index.js#L249

Describe alternatives you've considered no

Additional context Currently, whenever we request a value for a feature flag, the library will log a message if the feature flag does not exist.

This happens despite the fact that we provide a default value for a given feature flag.

This leads to an extremely high volume of log message.

kinyoklion commented 2 years ago

Hello @edxzh,

If you would like for this error to not be reported, then you can listen for error on the client, and the error will be reported there instead of being logged.

The reporter logic is as such.

    if (emitter.listenerCount('error')) {
      emitter.emit('error', error);
    } else {
      logger.error(error.message);
    }

This would apply to other maybe type errors as well. You could check the content and conditionally log it yourself if you wish.

Alternatively you could implement a custom logger, and filter out the corresponding messages.

The default value is not associated with a flag existing or not. For many people a flag not existing is representative of a problem. A typo in the flag name for instance.

Thank you, Ryan

edxzh commented 2 years ago

Hi @kinyoklion thanks for your reply, this makes sense to me, close this issue and you have a great one.