chore(message): Add option to redact contents of messages in logs (#719)

This commit is contained in:
Ethan Nguyen
2023-02-20 21:00:24 -06:00
committed by GitHub
parent 131e8a156b
commit a35fc9fbd2
7 changed files with 42 additions and 25 deletions

View File

@@ -10,7 +10,7 @@ import (
"github.com/spf13/viper"
)
//nolint
// nolint
var defaultConf = []byte(`
core:
enabled: true # enable httpd server
@@ -98,6 +98,7 @@ log:
error_log: "stderr" # stderr: output to console, or define log path like "log/error_log"
error_level: "error"
hide_token: true
hide_messages: false
stat:
engine: "memory" # support memory, redis, boltdb, buntdb or leveldb
@@ -202,12 +203,13 @@ type SectionIos struct {
// SectionLog is sub section of config.
type SectionLog struct {
Format string `yaml:"format"`
AccessLog string `yaml:"access_log"`
AccessLevel string `yaml:"access_level"`
ErrorLog string `yaml:"error_log"`
ErrorLevel string `yaml:"error_level"`
HideToken bool `yaml:"hide_token"`
Format string `yaml:"format"`
AccessLog string `yaml:"access_log"`
AccessLevel string `yaml:"access_level"`
ErrorLog string `yaml:"error_log"`
ErrorLevel string `yaml:"error_level"`
HideToken bool `yaml:"hide_token"`
HideMessages bool `yaml:"hide_messages"`
}
// SectionStat is sub section of config.
@@ -397,6 +399,7 @@ func LoadConf(confPath ...string) (*ConfYaml, error) {
conf.Log.ErrorLog = viper.GetString("log.error_log")
conf.Log.ErrorLevel = viper.GetString("log.error_level")
conf.Log.HideToken = viper.GetBool("log.hide_token")
conf.Log.HideMessages = viper.GetBool("log.hide_messages")
// Queue Engine
conf.Queue.Engine = viper.GetString("queue.engine")

View File

@@ -119,6 +119,7 @@ func (suite *ConfigTestSuite) TestValidateConfDefault() {
assert.Equal(suite.T(), "stderr", suite.ConfGorushDefault.Log.ErrorLog)
assert.Equal(suite.T(), "error", suite.ConfGorushDefault.Log.ErrorLevel)
assert.Equal(suite.T(), true, suite.ConfGorushDefault.Log.HideToken)
assert.Equal(suite.T(), false, suite.ConfGorushDefault.Log.HideMessages)
assert.Equal(suite.T(), "memory", suite.ConfGorushDefault.Stat.Engine)
assert.Equal(suite.T(), false, suite.ConfGorushDefault.Stat.Redis.Cluster)

View File

@@ -84,6 +84,7 @@ log:
error_log: "stderr" # stderr: output to console, or define log path like "log/error_log"
error_level: "error"
hide_token: true
hide_messages: false
stat:
engine: "memory" # support memory, redis, boltdb, buntdb or leveldb