Skip to content

Commit

Permalink
Fix debug logging (#4739)
Browse files Browse the repository at this point in the history
## Motivation
#4728 broke debug logging, this reverts part of the PR to make it possible to log debug messages again when enabled via config.

## Changes
Revert some changes from #4728 

## Test Plan
n/a

## TODO
<!-- This section should be removed when all items are complete -->
- [x] Explain motivation or link existing issue(s)
- [x] Test changes and document test plan
- [x] Update documentation as needed

## DevOps Notes
<!-- Please uncheck these items as applicable to make DevOps aware of changes that may affect releases -->
- [x] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources)
- [x] This PR does not affect public APIs
- [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)
- [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on)
  • Loading branch information
fasmat committed Jul 21, 2023
1 parent 88890f4 commit bc93994
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func GetCommand() *cobra.Command {
// NOTE(dshulyak) this needs to be max level so that child logger can can be current level or below.
// otherwise it will fail later when child logger will try to increase level.
WithLog(log.RegisterHooks(
log.NewWithLevel("node", zap.NewAtomicLevelAt(zap.InfoLevel)),
log.NewWithLevel("node", zap.NewAtomicLevelAt(zap.DebugLevel)),
events.EventHook()),
),
)
Expand Down Expand Up @@ -294,7 +294,12 @@ func New(opts ...Option) *App {
for _, opt := range opts {
opt(app)
}
log.SetupGlobal(app.log)
// TODO(mafa): this is a hack to suppress debugging logs on 0000.defaultLogger
// to fix this we should get rid of the global logger and pass app.log to all
// components that need it
lvl := zap.NewAtomicLevelAt(zap.InfoLevel)
log.SetupGlobal(app.log.SetLevel(&lvl))

types.SetNetworkHRP(app.Config.NetworkHRP)
return app
}
Expand Down
4 changes: 2 additions & 2 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ func TestSpacemeshApp_JsonService(t *testing.T) {

// E2E app test of the stream endpoints in the NodeService.
func TestSpacemeshApp_NodeService(t *testing.T) {
logger := logtest.New(t, zapcore.ErrorLevel)
errlog := log.RegisterHooks(logger, events.EventHook()) // errlog is used to simulate errors in the app
logger := logtest.New(t)
errlog := log.RegisterHooks(logtest.New(t, zap.ErrorLevel), events.EventHook()) // errlog is used to simulate errors in the app

// Use a unique port
port := 1240
Expand Down

0 comments on commit bc93994

Please sign in to comment.