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

Provide injectable logger instance #178

Closed
chingor13 opened this issue Mar 15, 2021 · 0 comments · Fixed by #206
Closed

Provide injectable logger instance #178

chingor13 opened this issue Mar 15, 2021 · 0 comments · Fixed by #206
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@chingor13
Copy link
Contributor

We currently default to a pino logger that outputs JSON compatible with GCP logging.

For integrations like CLI's that use code-suggester, we might want to log with something more CLI friendly.

@chingor13 chingor13 added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Mar 15, 2021
gcf-merge-on-green bot pushed a commit that referenced this issue Apr 23, 2021
This changes the logger option provided to `reviewPullRequest()` and `createPullRequest()` to be a custom `Logger` interface that `code-suggester` declares:

```ts
interface LogFn {
  /* eslint-disable @typescript-eslint/no-explicit-any */
  <T extends object>(obj: T, msg?: string, ...args: any[]): void;
  (msg: string, ...args: any[]): void;
  /* eslint-enable @typescript-eslint/no-explicit-any */
}

export interface Logger {
  error: LogFn;
  warn: LogFn;
  info: LogFn;
  debug: LogFn;
  trace: LogFn;
}
```

* This logger interface can be fulfilled by a default `Pino` logger as well as plain old `console`.
* We now default the logger to a null implementation to keep output to a minimum while allowing for a custom logger if you want output.
* We can drop the `pino` dependency as we now provide a null default logger implementation.

Fixes #178
Fixes #183
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant