forked from nspcc-dev/neofs-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nspcc-dev#1770] node: Support runtime re-configuration of the logger
There is a need to re-configure storage node's logging on the fly. Provide `SubscribeConfigChanges` function to listen to changes of the storage node config. Create dynamically configured `logger.Logger` in `neofs-node` app and use it to log notifications about new Sidechain blocks. Update `logger.Level` parameter on each `syscall.SIGHUP` signal. Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
- Loading branch information
1 parent
541bf3d
commit dfe3908
Showing
15 changed files
with
146 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" | ||
loggerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/logger" | ||
"github.com/nspcc-dev/neofs-node/pkg/util/logger" | ||
) | ||
|
||
type configLogger struct { | ||
level logger.Level | ||
} | ||
|
||
func (x *configLogger) read(c *config.Config) error { | ||
switch strLvl := loggerconfig.Level(c); strLvl { | ||
default: | ||
return fmt.Errorf("unsupported level %s", strLvl) | ||
case "debug": | ||
x.level = logger.LevelDebug | ||
case "info": | ||
x.level = logger.LevelInfo | ||
case "warn": | ||
x.level = logger.LevelWarn | ||
case "error": | ||
x.level = logger.LevelError | ||
} | ||
|
||
return nil | ||
} | ||
|
||
type runtimeConfigLogger struct { | ||
c logger.Config | ||
} | ||
|
||
func (x *runtimeConfigLogger) write(c configLogger) { | ||
x.c.SetLevel(c.level) | ||
} | ||
|
||
func bindRuntimeConfigLogger(l *logger.Logger, c *runtimeConfigLogger) error { | ||
err := logger.InitConfigurable(l, &c.c) | ||
if err != nil { | ||
return fmt.Errorf("init logger configurable at runtime: %w", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.