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: adding zerolog logging to cosmovisor #10217

Merged
merged 14 commits into from
Sep 28, 2021

Conversation

spoo-bar
Copy link
Contributor

@spoo-bar spoo-bar commented Sep 23, 2021

Description

Closes: #10058

  • Adding zerolog to cosmovisor
  • Replacing zerolog logger instead of println

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@github-actions github-actions bot added the C:Cosmovisor Issues and PR related to Cosmovisor label Sep 23, 2021
@spoo-bar spoo-bar marked this pull request as ready for review September 23, 2021 10:59
@tac0turtle
Copy link
Member

should we use the tendermint logger interface to be consistent with app.go?

cosmovisor/args.go Outdated Show resolved Hide resolved

var Logger zerolog.Logger

func SetupLogging() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not meaning to block here, but is there a reason to use a global here instead of just returning a logger instance?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You mean to have a function which returns a private instance? Or putting it in a context?

I think this is fine for the moment - it's still better than using fmt.Print*. Logger is not something that it's going to change during the runtime.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@spoo-bar - since nobody is blocking, feel free to add automerge unless you want to expand in this thread.

Copy link
Contributor

@alexanderbez alexanderbez Sep 26, 2021

Choose a reason for hiding this comment

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

Im not sure what you mean by private, but I mean just an instance, instead of relying on a global. So instead of requiring a SetupLogger call, you just call logger := CreateLogger().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexanderbez creating an instance would require logger to be passed around to each function.
having a global makes it easy to call it from anywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

creating an instance would require logger to be passed around to each function.

Not really, as the caller would would just call the function when it needs a logger (this is what SDK modules do BTW).

Also, globals are generally the root of all evil. Avoid them if possible (in most contexts).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah okay.
But it would still require frequent reinitialization all over. Idk if having it has a global for a small component like cosmovisor is all that bad, is it?


var Logger zerolog.Logger

func SetupLogging() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You mean to have a function which returns a private instance? Or putting it in a context?

I think this is fine for the moment - it's still better than using fmt.Print*. Logger is not something that it's going to change during the runtime.

@spoo-bar
Copy link
Contributor Author

@marbar3778 Using Zerolog directly, there are some really nice APIs we can use directly. Using the tendermint logger doesn't bring anything extra except consistency.
Additionally, cosmovisor currently isn't dependent on any cosmos or tendermint libraries. And adding a dependency just for logging might not be necessary in my opinion.

@spoo-bar spoo-bar added the A:automerge Automatically merge PR once all prerequisites pass. label Sep 28, 2021
@codecov
Copy link

codecov bot commented Sep 28, 2021

Codecov Report

Merging #10217 (d53deb2) into master (3138527) will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10217      +/-   ##
==========================================
- Coverage   63.65%   63.65%   -0.01%     
==========================================
  Files         573      573              
  Lines       53761    53761              
==========================================
- Hits        34222    34221       -1     
- Misses      17590    17591       +1     
  Partials     1949     1949              
Impacted Files Coverage Δ
crypto/keys/internal/ecdsa/privkey.go 82.45% <0.00%> (-1.76%) ⬇️

@amaury1093 amaury1093 merged commit e9390df into master Sep 28, 2021
@amaury1093 amaury1093 deleted the spoorthi/10058-cosmovisor-logging branch September 28, 2021 10:26
@robert-zaremba robert-zaremba mentioned this pull request Sep 28, 2021
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:Cosmovisor Issues and PR related to Cosmovisor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add better logging management in Cosmovisor.
7 participants