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