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

feat!: cleanup custom logging #206

Merged
merged 4 commits into from Apr 23, 2021

Conversation

chingor13
Copy link
Contributor

This changes the logger option provided to reviewPullRequest() and createPullRequest() to be a custom Logger interface that code-suggester declares:

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

BREAKING CHANGE: changes the interface to provide a custom logger to our
own types, rather than exposing Pino's types.
@chingor13 chingor13 requested a review from a team April 21, 2021 22:13
@chingor13 chingor13 requested a review from a team as a code owner April 21, 2021 22:13
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Apr 21, 2021
@codecov
Copy link

codecov bot commented Apr 21, 2021

Codecov Report

Merging #206 (391aaad) into master (3d4aa4b) will increase coverage by 0.27%.
The diff coverage is 97.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #206      +/-   ##
==========================================
+ Coverage   88.04%   88.32%   +0.27%     
==========================================
  Files          24       24              
  Lines        2301     2329      +28     
  Branches      168      168              
==========================================
+ Hits         2026     2057      +31     
+ Misses        275      272       -3     
Impacted Files Coverage Δ
src/bin/handle-git-dir-change.ts 79.28% <0.00%> (ø)
src/github-handler/pull-request-handler.ts 100.00% <100.00%> (ø)
src/index.ts 98.73% <100.00%> (+<0.01%) ⬆️
src/logger.ts 100.00% <100.00%> (+11.11%) ⬆️
src/types.ts 98.45% <100.00%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6719b68...391aaad. Read the comment docs.

Copy link
Contributor

@JustinBeckwith JustinBeckwith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

@chingor13 chingor13 added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 22, 2021
@chingor13
Copy link
Contributor Author

going to release a candidate version and batch some other potentially breaking cleanup changes.

@chingor13 chingor13 removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 23, 2021
@chingor13
Copy link
Contributor Author

Released this as 2.0.0-candidate.1 and it integrates fine with release-please.

@chingor13 chingor13 added automerge Merge the pull request once unit tests and other checks pass. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 23, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 23, 2021
@gcf-merge-on-green gcf-merge-on-green bot merged commit 3e4df30 into googleapis:master Apr 23, 2021
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Apr 23, 2021
@release-please release-please bot mentioned this pull request Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Libraries shouldn't emit logs Provide injectable logger instance
4 participants