vechain / thor

A general purpose blockchain highly compatible with Ethereum's ecosystem
GNU Lesser General Public License v3.0
791 stars 247 forks source link

feat: use built in slog package #749

Open darrenvechain opened 1 month ago

darrenvechain commented 1 month ago

Description

Use the built in slog package. log package copied from latest geth. Also introduced a new flag --json-logs which will output the logs in JSON format.

Type of change

How Has This Been Tested?

Checklist:

codecov-commenter commented 1 month ago

Codecov Report

Attention: Patch coverage is 45.34161% with 352 lines in your changes missing coverage. Please review.

Project coverage is 62.21%. Comparing base (3d7ab12) to head (a6111f0).

Files Patch % Lines
log/format.go 62.89% 67 Missing and 15 partials :warning:
log/logger.go 35.63% 55 Missing and 1 partial :warning:
log/handler.go 48.93% 46 Missing and 2 partials :warning:
log/handler_glog.go 55.84% 25 Missing and 9 partials :warning:
cmd/thor/utils.go 0.00% 33 Missing :warning:
cmd/thor/node/node.go 0.00% 31 Missing :warning:
log/root.go 8.69% 21 Missing :warning:
cmd/thor/node/packer_loop.go 0.00% 12 Missing :warning:
p2psrv/server.go 10.00% 9 Missing :warning:
cmd/thor/solo/solo.go 37.50% 5 Missing :warning:
... and 10 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #749 +/- ## ========================================== - Coverage 62.58% 62.21% -0.37% ========================================== Files 199 204 +5 Lines 18098 18634 +536 ========================================== + Hits 11326 11593 +267 - Misses 5690 5932 +242 - Partials 1082 1109 +27 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

darrenvechain commented 1 month ago

@libotony do you know a way to trigger a test log from:

ethlog "github.com/ethereum/go-ethereum/log"

Previously it was configured like so:

        ethLogHandler := ethlog.NewGlogHandler(ethlog.StreamHandler(os.Stderr, ethlog.TerminalFormat(true)))
    ethLogHandler.Verbosity(ethlog.LvlWarn)
    ethlog.Root().SetHandler(ethLogHandler)
libotony commented 1 month ago

@libotony do you know a way to trigger a test log from:

ethlog "github.com/ethereum/go-ethereum/log"

Previously it was configured like so:

        ethLogHandler := ethlog.NewGlogHandler(ethlog.StreamHandler(os.Stderr, ethlog.TerminalFormat(true)))
  ethLogHandler.Verbosity(ethlog.LvlWarn)
  ethlog.Root().SetHandler(ethLogHandler)

You can create an eth logger doing that. If I remember correctly, it was inside the discovery package, you can tweak the verbosity of eth logger to 6 or 9, will trigger the log output.