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

Libraries shouldn't emit logs #183

Closed
JustinBeckwith opened this issue Mar 21, 2021 · 2 comments · Fixed by #206
Closed

Libraries shouldn't emit logs #183

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

Comments

@JustinBeckwith
Copy link
Contributor

I'm using this as a library in a bot. When running locally via the CLI, it's outputting structured logs. For the GitHub Action portion of this, that may make sense. But for a server-side library, it should integrate with the existing logging subsystem.

@JustinBeckwith JustinBeckwith added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Mar 21, 2021
@chingor13
Copy link
Contributor

Would #178 with a no-op default logger solve this?

@JustinBeckwith
Copy link
Contributor Author

yup

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.

2 participants