mirror of
https://github.com/mudler/luet.git
synced 2025-09-02 15:54:39 +00:00
logger: Add support for json format
This commit is contained in:
@@ -10,6 +10,9 @@
|
|||||||
# Set logging level: error|warning|info|debug
|
# Set logging level: error|warning|info|debug
|
||||||
# level: "info"
|
# level: "info"
|
||||||
#
|
#
|
||||||
|
# Enable JSON log format instead of console mode.
|
||||||
|
# json_format: false.
|
||||||
|
#
|
||||||
# ---------------------------------------------
|
# ---------------------------------------------
|
||||||
# General configuration section:
|
# General configuration section:
|
||||||
# ---------------------------------------------
|
# ---------------------------------------------
|
||||||
|
@@ -28,6 +28,7 @@ var LuetCfg = NewLuetConfig(v.GetViper())
|
|||||||
|
|
||||||
type LuetLoggingConfig struct {
|
type LuetLoggingConfig struct {
|
||||||
Path string `mapstructure:"path"`
|
Path string `mapstructure:"path"`
|
||||||
|
JsonFormat bool `mapstructure:"json_format"`
|
||||||
Level string `mapstructure:"level"`
|
Level string `mapstructure:"level"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +102,7 @@ func GenDefault(viper *v.Viper) {
|
|||||||
|
|
||||||
viper.SetDefault("logging.level", "info")
|
viper.SetDefault("logging.level", "info")
|
||||||
viper.SetDefault("logging.path", "")
|
viper.SetDefault("logging.path", "")
|
||||||
|
viper.SetDefault("logging.json_format", false)
|
||||||
|
|
||||||
viper.SetDefault("general.concurrency", runtime.NumCPU())
|
viper.SetDefault("general.concurrency", runtime.NumCPU())
|
||||||
viper.SetDefault("general.debug", false)
|
viper.SetDefault("general.debug", false)
|
||||||
@@ -158,7 +160,8 @@ func (c *LuetLoggingConfig) String() string {
|
|||||||
ans := fmt.Sprintf(`
|
ans := fmt.Sprintf(`
|
||||||
logging:
|
logging:
|
||||||
path: %s
|
path: %s
|
||||||
level: %s`, c.Path, c.Level)
|
json_format: %t
|
||||||
|
level: %s`, c.Path, c.JsonFormat, c.Level)
|
||||||
|
|
||||||
return ans
|
return ans
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user