Commit 6a5f4bf9 by 杨树贤

日志配置文件

parent a44a403c
Showing with 14 additions and 2 deletions
...@@ -26,3 +26,7 @@ MaxIdle = 30 ...@@ -26,3 +26,7 @@ MaxIdle = 30
MaxActive = 30 MaxActive = 30
IdleTimeout = 200 IdleTimeout = 200
DBNum = 0 DBNum = 0
[log]
LogPath = 'logs/'
LogChanSize = 1000
\ No newline at end of file
...@@ -61,9 +61,15 @@ type Redis struct { ...@@ -61,9 +61,15 @@ type Redis struct {
var RedisSetting = &Redis{} var RedisSetting = &Redis{}
type Log struct {
LogPath string
LogChanSize string
}
var LogSetting = &Log{}
var cfg *ini.File var cfg *ini.File
// Setup initialize the configuration instance
func Setup() { func Setup() {
var err error var err error
cfg, err = ini.Load("conf/app.ini") cfg, err = ini.Load("conf/app.ini")
...@@ -75,6 +81,7 @@ func Setup() { ...@@ -75,6 +81,7 @@ func Setup() {
mapTo("server", ServerSetting) mapTo("server", ServerSetting)
mapTo("database", DatabaseSetting) mapTo("database", DatabaseSetting)
mapTo("redis", RedisSetting) mapTo("redis", RedisSetting)
mapTo("log", LogSetting)
AppSetting.ImageMaxSize = AppSetting.ImageMaxSize * 1024 * 1024 AppSetting.ImageMaxSize = AppSetting.ImageMaxSize * 1024 * 1024
ServerSetting.ReadTimeout = ServerSetting.ReadTimeout * time.Second ServerSetting.ReadTimeout = ServerSetting.ReadTimeout * time.Second
...@@ -82,7 +89,7 @@ func Setup() { ...@@ -82,7 +89,7 @@ func Setup() {
RedisSetting.IdleTimeout = RedisSetting.IdleTimeout * time.Second RedisSetting.IdleTimeout = RedisSetting.IdleTimeout * time.Second
} }
// mapTo map section //映射到配置文件的配置项
func mapTo(section string, v interface{}) { func mapTo(section string, v interface{}) {
err := cfg.Section(section).MapTo(v) err := cfg.Section(section).MapTo(v)
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment