[#1366] node, ir: Support timestamp
config option, update tests
All checks were successful
DCO action / DCO (pull_request) Successful in 1m12s
Tests and linters / Run gofumpt (pull_request) Successful in 1m18s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m8s
Vulncheck / Vulncheck (pull_request) Successful in 2m6s
Build / Build Components (pull_request) Successful in 2m37s
Tests and linters / gopls check (pull_request) Successful in 2m50s
Tests and linters / Staticcheck (pull_request) Successful in 3m2s
Tests and linters / Lint (pull_request) Successful in 3m10s
Tests and linters / Tests (pull_request) Successful in 6m19s
Tests and linters / Tests with -race (pull_request) Successful in 6m25s
All checks were successful
DCO action / DCO (pull_request) Successful in 1m12s
Tests and linters / Run gofumpt (pull_request) Successful in 1m18s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m8s
Vulncheck / Vulncheck (pull_request) Successful in 2m6s
Build / Build Components (pull_request) Successful in 2m37s
Tests and linters / gopls check (pull_request) Successful in 2m50s
Tests and linters / Staticcheck (pull_request) Successful in 3m2s
Tests and linters / Lint (pull_request) Successful in 3m10s
Tests and linters / Tests (pull_request) Successful in 6m19s
Tests and linters / Tests with -race (pull_request) Successful in 6m25s
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
bcc7d0f1cc
commit
8eff648791
11 changed files with 24 additions and 1 deletions
|
@ -41,6 +41,8 @@ func reloadConfig() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logPrm.PrependTimestamp = cfg.GetBool("logger.timestamp")
|
||||
|
||||
return logPrm.Reload()
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
func defaultConfiguration(cfg *viper.Viper) {
|
||||
cfg.SetDefault("logger.level", "info")
|
||||
cfg.SetDefault("logger.destination", "stdout")
|
||||
cfg.SetDefault("logger.timestamp", false)
|
||||
|
||||
setPprofDefaults(cfg)
|
||||
|
||||
|
|
|
@ -79,6 +79,8 @@ func main() {
|
|||
)
|
||||
exitErr(err)
|
||||
logPrm.SamplingHook = metrics.LogMetrics().GetSamplingHook()
|
||||
logPrm.PrependTimestamp = cfg.GetBool("logger.timestamp")
|
||||
|
||||
log, err = logger.NewLogger(logPrm)
|
||||
exitErr(err)
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ type applicationConfiguration struct {
|
|||
LoggerCfg struct {
|
||||
level string
|
||||
destination string
|
||||
timestamp bool
|
||||
}
|
||||
|
||||
EngineCfg struct {
|
||||
|
@ -220,6 +221,7 @@ func (a *applicationConfiguration) readConfig(c *config.Config) error {
|
|||
|
||||
a.LoggerCfg.level = loggerconfig.Level(c)
|
||||
a.LoggerCfg.destination = loggerconfig.Destination(c)
|
||||
a.LoggerCfg.timestamp = loggerconfig.Timestamp(c)
|
||||
|
||||
// Storage Engine
|
||||
|
||||
|
@ -1023,6 +1025,7 @@ func (c *cfg) loggerPrm() (*logger.Prm, error) {
|
|||
// not expected since validation should be performed before
|
||||
panic("incorrect log destination format: " + c.LoggerCfg.destination)
|
||||
}
|
||||
c.dynamicConfiguration.logger.PrependTimestamp = c.LoggerCfg.timestamp
|
||||
|
||||
return c.dynamicConfiguration.logger, nil
|
||||
}
|
||||
|
|
|
@ -52,6 +52,14 @@ func Destination(c *config.Config) string {
|
|||
return DestinationDefault
|
||||
}
|
||||
|
||||
// Timestamp returns the value of "timestamp" config parameter
|
||||
// from "logger" section.
|
||||
//
|
||||
// Returns false if the value isn't specified.
|
||||
func Timestamp(c *config.Config) bool {
|
||||
return config.BoolSafe(c.Sub(subsection), "timestamp")
|
||||
}
|
||||
|
||||
// ToLokiConfig extracts loki config.
|
||||
func ToLokiConfig(c *config.Config) loki.Config {
|
||||
hostname, _ := os.Hostname()
|
||||
|
|
|
@ -13,6 +13,7 @@ func TestLoggerSection_Level(t *testing.T) {
|
|||
t.Run("defaults", func(t *testing.T) {
|
||||
require.Equal(t, loggerconfig.LevelDefault, loggerconfig.Level(configtest.EmptyConfig()))
|
||||
require.Equal(t, loggerconfig.DestinationDefault, loggerconfig.Destination(configtest.EmptyConfig()))
|
||||
require.Equal(t, false, loggerconfig.Timestamp(configtest.EmptyConfig()))
|
||||
})
|
||||
|
||||
const path = "../../../../config/example/node"
|
||||
|
@ -20,6 +21,7 @@ func TestLoggerSection_Level(t *testing.T) {
|
|||
fileConfigTest := func(c *config.Config) {
|
||||
require.Equal(t, "debug", loggerconfig.Level(c))
|
||||
require.Equal(t, "journald", loggerconfig.Destination(c))
|
||||
require.Equal(t, true, loggerconfig.Timestamp(c))
|
||||
}
|
||||
|
||||
configtest.ForEachFileType(path, fileConfigTest)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
FROSTFS_IR_LOGGER_LEVEL=info
|
||||
FROSTFS_IR_LOGGER_TIMESTAMP=true
|
||||
|
||||
FROSTFS_IR_WALLET_PATH=/path/to/wallet.json
|
||||
FROSTFS_IR_WALLET_ADDRESS=NUHtW3eM6a4mmFCgyyr4rj4wygsTKB88XX
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
logger:
|
||||
level: info # Logger level: one of "debug", "info" (default), "warn", "error", "dpanic", "panic", "fatal"
|
||||
timestamp: true
|
||||
|
||||
wallet:
|
||||
path: /path/to/wallet.json # Path to NEP-6 NEO wallet file
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
FROSTFS_LOGGER_LEVEL=debug
|
||||
FROSTFS_LOGGER_DESTINATION=journald
|
||||
FROSTFS_LOGGER_TIMESTAMP=true
|
||||
|
||||
FROSTFS_PPROF_ENABLED=true
|
||||
FROSTFS_PPROF_ADDRESS=localhost:6060
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"logger": {
|
||||
"level": "debug",
|
||||
"destination": "journald"
|
||||
"destination": "journald",
|
||||
"timestamp": true
|
||||
},
|
||||
"pprof": {
|
||||
"enabled": true,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
logger:
|
||||
level: debug # logger level: one of "debug", "info" (default), "warn", "error", "dpanic", "panic", "fatal"
|
||||
destination: journald # logger destination: one of "stdout" (default), "journald"
|
||||
timestamp: true
|
||||
|
||||
systemdnotify:
|
||||
enabled: true
|
||||
|
|
Loading…
Reference in a new issue