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

⚠️ Create a dedicated logging package to encapsulate calls to zap #1502

Merged
merged 6 commits into from
Jan 20, 2022

Conversation

justaugustus
Copy link
Member

@justaugustus justaugustus commented Jan 20, 2022

  • Please check if the PR fulfills these requirements

    • Tests for the changes have been added (for bug fixes / features)

      We're roughly mimicking existing functionality and the interface may change in future. Logging usage that has changed exists in packages that already have test coverage.

      tl;dr -- If existing tests pass, we should be fine here.

    • PR title follows the guidelines defined in https://github.com/ossf/scorecard/blob/main/CONTRIBUTING.md#pr-process

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

    Introduces a logging package to eventually replace go.uber.org/zap.
    Here we're effectively quarantining usage of the go.uber.org/zap and go.uber.org/zap/zapcore to a single package, log.

  • What is the current behavior? (You can also link to an open issue here)

    See Should scorecard be forcing users to use a zap.Logger? #1273.

  • What is the new behavior (if this is a feature change)?

    Functions that create instances of zap.Logger now create instances of log.Logger:

    type Logger struct {
        Zap *zap.Logger
    }

    ...which means usage of zap will now look something like:

    logger.Zap.Info()

    As @jeffmendoza mentions in Should scorecard be forcing users to use a zap.Logger? #1273 (comment):

    Ideally CreateGitHubRepoClient() can be refactored to take a DetailLogger instead of a zap.Logger.

    the goal would to support logging without zap, opting to use DetailLogger instead.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

    Consumers of functions like:

    func CreateGithubRepoClient(ctx context.Context, logger *zap.Logger) clients.RepoClient { ... }

    will need to use log.Logger as an argument:

    func CreateGithubRepoClient(ctx context.Context, logger *log.Logger) clients.RepoClient { ... }

    as well as update log calls from:

    ghClient := CreateGithubRepoClient(ctx, logger)
    logger.Info(...)

    to:

    ghClient := CreateGithubRepoClient(ctx, logger)
    logger.Zap.Info(...)
  • Other information:

@justaugustus justaugustus changed the title Zap zapped [WIP] Zap zapped Jan 20, 2022
@justaugustus justaugustus temporarily deployed to integration-test January 20, 2022 19:36 Inactive
@github-actions
Copy link

Integration tests success for
[e22f61e]
(https://github.com/ossf/scorecard/actions/runs/1725243558)

@justaugustus justaugustus changed the title [WIP] Zap zapped 🌱 [WIP] Zap zapped Jan 20, 2022
@naveensrinivasan naveensrinivasan temporarily deployed to integration-test January 20, 2022 20:11 Inactive
@github-actions
Copy link

Integration tests success for
[c36a736]
(https://github.com/ossf/scorecard/actions/runs/1725374829)

Creates a wrapper around existing `zap.Logger` to make it easier
to replace/extend with scorecard logging.

Signed-off-by: Stephen Augustus <[email protected]>
@justaugustus justaugustus temporarily deployed to integration-test January 20, 2022 21:40 Inactive
@github-actions
Copy link

Integration tests success for
[37d746b]
(https://github.com/ossf/scorecard/actions/runs/1725718390)

@justaugustus justaugustus changed the title 🌱 [WIP] Zap zapped ⚠️ Create a dedicated logging package to encapsulate calls to zap Jan 20, 2022
@justaugustus justaugustus temporarily deployed to integration-test January 20, 2022 22:22 Inactive
@justaugustus
Copy link
Member Author

@inferno-chromium @naveensrinivasan @azeemshaikh38 @laurentsimon @olivekl @jeffmendoza -- This is in a good place for initial review. I don't want run to far ahead in case there's something design-wise that needs fixing.

@github-actions
Copy link

Integration tests success for
[4b356a6]
(https://github.com/ossf/scorecard/actions/runs/1725867915)

@naveensrinivasan
Copy link
Member

I had a quick look and 👍. I will let @azeemshaikh38 and @laurentsimon chime in

@justaugustus
Copy link
Member Author

I had a quick look and 👍. I will let @azeemshaikh38 and @laurentsimon chime in

Thanks so much, Naveen!

Copy link
Contributor

@azeemshaikh38 azeemshaikh38 left a comment

Choose a reason for hiding this comment

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

This looks awesome @justaugustus, thanks!

log/log.go Show resolved Hide resolved
@justaugustus justaugustus temporarily deployed to integration-test January 20, 2022 23:26 Inactive
@justaugustus
Copy link
Member Author

justaugustus commented Jan 20, 2022

@naveensrinivasan @azeemshaikh38 -- Fixed up the reviews. Should be good to retrigger CI on :)

@naveensrinivasan
Copy link
Member

@ naveensrinivasan @azeemshaikh38 -- Fixed up the reviews. Should be good to retrigger CI on :)

Thanks!

@github-actions
Copy link

Integration tests success for
[ac1d50f]
(https://github.com/ossf/scorecard/actions/runs/1726086387)

@codecov-commenter
Copy link

Codecov Report

Merging #1502 (ac1d50f) into main (f4e9dfd) will increase coverage by 0.01%.
The diff coverage is 41.17%.

@@            Coverage Diff             @@
##             main    #1502      +/-   ##
==========================================
+ Coverage   50.42%   50.43%   +0.01%     
==========================================
  Files          68       68              
  Lines        6071     6069       -2     
==========================================
  Hits         3061     3061              
+ Misses       2809     2807       -2     
  Partials      201      201              

@azeemshaikh38
Copy link
Contributor

Thanks @justaugustus, looks good to merge to me.

Copy link
Contributor

@laurentsimon laurentsimon left a comment

Choose a reason for hiding this comment

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

Just wanted to join and say thanks! This is a massive PR!

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

Successfully merging this pull request may close these issues.

5 participants