From ccb6685b1b28dcd7d376887504cd98b5cd410b44 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期二, 12 三月 2024 17:56:01 +0800 Subject: [PATCH] 添加日志打印 --- config/config.go | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index 0f86c14..de15231 100644 --- a/config/config.go +++ b/config/config.go @@ -7,12 +7,22 @@ ) type common struct { - EsUrl string `mapstructure: "esUrl"` - ServerUrl string `mapstructure: "serverUrl"` - OrgName string `mapstructure: "orgName"` + EsUrl string `mapstructure:"esUrl"` + ServerUrl string `mapstructure:"serverUrl"` + OrgName string `mapstructure:"orgName"` + Interval int `mapstructure:"pushInterval"` +} + +type logConfig struct { + Path string `mapstructure:"path"` //鏃ュ織瀛樺偍璺緞 + Level int `mapstructure:"level"` //鏃ュ織绛夌骇 + MaxSize int `mapstructure:"maxSize"` //鏃ュ織鏂囦欢澶у皬涓婇檺 + MaxBackups int `mapstructure:"maxBackups"` //鏃ュ織鍘嬬缉鍖呬釜鏁� + MaxAge int `mapstructure:"maxAge"` //淇濈暀鍘嬬缉鍖呭ぉ鏁� } var Options = &common{} +var LogConf = &logConfig{} func Init() { var err error @@ -27,6 +37,8 @@ } viper.UnmarshalKey("common", Options) + viper.UnmarshalKey("log", LogConf) + viper.WatchConfig() viper.OnConfigChange(func(in fsnotify.Event) { viper.UnmarshalKey("common", Options) -- Gitblit v1.8.0