launchdarkly / node-server-sdk

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

Flushing %d events #257

Closed tommoor closed 2 years ago

tommoor commented 2 years ago

Describe the bug The SDK constantly prints "Flushing %d events" to the console.

image

Expected behavior

Additional context

https://github.com/launchdarkly/node-server-sdk/blob/7098956adb4ba466756d875fceccac8d63b24950/event_processor.js#L217

kinyoklion commented 2 years ago

Hello @tommoor,

Are you using a custom logger with your SDK? The basic logger uses line = util.format(...tempArgs); to interpolate log lines.

Here is some output using the basicLogger provided with the SDK. Adjusted to show debug level items.

debug: [LaunchDarkly] Flushing 21 events

The creation of the logger:

  basicLogger({
    level: 'debug',
  });

You can also use the basic logger and change the destination.

basicLogger({
    level: 'debug',
    destination: line => {
      console.log(line);
    },
  });

If you are directly implementing the LDLogger interface, then it receives variadic arguments and you need to interpolate them.

The first of the args will be the format string, then any additional args.

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

Produces:

Flushing 2 events

Thank you! Ryan

tommoor commented 2 years ago

Thanks, looks like this is an issue with our implementation of the interface then 👍