Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logger expects bunyan #39

Open
cramhead opened this issue Oct 13, 2020 · 2 comments
Open

Logger expects bunyan #39

cramhead opened this issue Oct 13, 2020 · 2 comments

Comments

@cramhead
Copy link

Thanks for making this package. I think it's really great.

I notice that logger method used are only debug, warn, info, and error, but when I pass my logger that supports those function I get the following.

error TS2345: Argument of type 'MyLogger' is not assignable to parameter of type 'Logger'.
  Type 'IsamLogger' is missing the following properties from type 'Logger': addStream, addSerializers, child, reopenFileStreams, and 21 more.

It's problematic to support all the interfaces that bunyan offers.

@nick4fake
Copy link

Temporary solution:

class LogBunyan {
  constructor(
    private logger: Logger,
  ) {
  }

  child() {
    return ({
      log: (...args: any[]) => this.logger.log(args.join(', ')),
      debug: (...args: any[]) => this.logger.debug(args.join(', ')),
      error: (...args: any[]) => this.logger.error(args.join(', ')),
      warn: (...args: any[]) => this.logger.warn(args.join(', ')),
      info: (...args: any[]) => this.logger.log(args.join(', ')),
    });
  }
}
new KafkaPubSub({
  topic,
  host,
  port,
  groupId,
  logger: new LogBunyan(logger) as unknown as BunyanLogger,
  globalConfig: {},
});

@psugasti
Copy link

how can I use my own log into graphql-kafka-subscriptions ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants