Skip to content

improvement: refactor Tendermint logger by using zerolog#6534

Merged
alexanderbez merged 25 commits intomasterfrom
bez/refactor-logger
Jun 7, 2021
Merged

improvement: refactor Tendermint logger by using zerolog#6534
alexanderbez merged 25 commits intomasterfrom
bez/refactor-logger

Conversation

@alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Jun 3, 2021

Remove a lot of custom logging code in favor of a simple wrapper around zerolog. The interface and auxiliary types (testing and nop) remain.

NOTE: This removes the ability for Tendermint's default logger to provide field filtering, e.g. abci:info.

@alexanderbez alexanderbez changed the title improvement: refactor Tendermint logger improvement: refactor Tendermint logger by using zerolog Jun 3, 2021
@tychoish
Copy link
Contributor

tychoish commented Jun 3, 2021

Is there some conversation somewhere that I've missed as to why this logger is better than other loggers, or where we decided to change?

@tac0turtle
Copy link
Contributor

Is there some conversation somewhere that I've missed as to why this logger is better than other loggers, or where we decided to change?

#3428 although the title says zap the conversation says zero log. Also apps can easily override, and many do, the logger. I would say this is more of reducing maintenance burden of a custom logger.

@alexanderbez
Copy link
Contributor Author

alexanderbez commented Jun 3, 2021

No major discussions @tychoish. We expose a Logger interface that applications can use to implement/provide whatever loggers they like (SDK uses zerolog).

Tendermint implements a "default" one, but it was an archaic and convoluted series of wrappers around go-kit and very slow compared to zerolog, which is very performant and has good ergonomics.

Copy link
Contributor

@tychoish tychoish left a comment

Choose a reason for hiding this comment

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

not that logging performance is really ever an issue, but...

@alexanderbez alexanderbez marked this pull request as ready for review June 3, 2021 21:08
@alexanderbez
Copy link
Contributor Author

We need the logger to be thread-safe, which zerolog supports...I'm gonna put this PR on pause.

@alexanderbez alexanderbez marked this pull request as draft June 3, 2021 21:52
@tac0turtle
Copy link
Contributor

not that logging performance is really ever an issue, but...

It has caused issues in the past at least in some testing areas.

Not sure that there needs to be a further discussion here, does there? The pr is already here, lets just wrap it up and merge it. Less code is always better, IMO.

@tychoish
Copy link
Contributor

tychoish commented Jun 3, 2021

It has caused issues in the past at least in some testing areas.

The testing logger problem is almost certainly not about the raw speed of the logger and rather about the volume of log messages when the system runs quickly (combined with the way that the testing logger writes to standard output, and the logger is multiplexed between tests.

I agree, however, that this is a fine change.

@alexanderbez
Copy link
Contributor Author

It's a win for two reasons: (1) We have a more performant logger (which does matter, albeit can be little), and (2) we removed +1k lines of useless code.

@tychoish
Copy link
Contributor

tychoish commented Jun 4, 2021

Yeah, let's do it.

@alexanderbez alexanderbez marked this pull request as ready for review June 4, 2021 12:44
@alexanderbez alexanderbez marked this pull request as draft June 4, 2021 12:57
Copy link
Contributor

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +27 to +29
LogLevelWarn = "warn"
LogLevelError = "error"
LogLevelFatal = "fatal"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we support warn and fatal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't technically, although I think we should support warn at the least. What do you think? I'll remove fatal.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, do you need to update the interface to expose it as well?

@codecov
Copy link

codecov bot commented Jun 4, 2021

Codecov Report

Merging #6534 (2f572b7) into master (eaa0468) will decrease coverage by 0.05%.
The diff coverage is 39.70%.

@@            Coverage Diff             @@
##           master    #6534      +/-   ##
==========================================
- Coverage   60.50%   60.44%   -0.06%     
==========================================
  Files         299      294       -5     
  Lines       27883    27703     -180     
==========================================
- Hits        16870    16746     -124     
+ Misses       9296     9251      -45     
+ Partials     1717     1706      -11     
Impacted Files Coverage Δ
libs/log/nop.go 0.00% <0.00%> (ø)
libs/log/testing.go 0.00% <0.00%> (ø)
test/e2e/generator/main.go 0.00% <ø> (ø)
libs/log/logger.go 25.00% <25.00%> (+25.00%) ⬆️
libs/service/service.go 56.81% <37.50%> (+1.49%) ⬆️
cmd/tendermint/commands/light.go 24.27% <40.00%> (+1.63%) ⬆️
libs/log/default.go 50.00% <50.00%> (ø)
cmd/tendermint/commands/root.go 50.00% <100.00%> (+7.14%) ⬆️
config/config.go 74.84% <100.00%> (ø)
blockchain/v0/pool.go 74.52% <0.00%> (-7.99%) ⬇️
... and 13 more

@alexanderbez alexanderbez marked this pull request as ready for review June 4, 2021 19:51
@tac0turtle
Copy link
Contributor

NOTE: This removes the ability for Tendermint's default logger to provide field filtering, e.g. abci:info.

docs need to be updated to reflect this. Mainly logging.md

@alexanderbez alexanderbez merged commit 3635c7a into master Jun 7, 2021
@alexanderbez alexanderbez deleted the bez/refactor-logger branch June 7, 2021 12:30
@alexanderbez alexanderbez mentioned this pull request Jun 14, 2022
4 tasks
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.

3 participants