Commit 6a5f4bf9 by 杨树贤

日志配置文件

parent a44a403c
Showing with 15 additions and 4 deletions
......@@ -25,4 +25,8 @@ Password =
MaxIdle = 30
MaxActive = 30
IdleTimeout = 200
DBNum = 0
\ No newline at end of file
DBNum = 0
[log]
LogPath = 'logs/'
LogChanSize = 1000
\ No newline at end of file
......@@ -61,9 +61,15 @@ type Redis struct {
var RedisSetting = &Redis{}
type Log struct {
LogPath string
LogChanSize string
}
var LogSetting = &Log{}
var cfg *ini.File
// Setup initialize the configuration instance
func Setup() {
var err error
cfg, err = ini.Load("conf/app.ini")
......@@ -75,6 +81,7 @@ func Setup() {
mapTo("server", ServerSetting)
mapTo("database", DatabaseSetting)
mapTo("redis", RedisSetting)
mapTo("log", LogSetting)
AppSetting.ImageMaxSize = AppSetting.ImageMaxSize * 1024 * 1024
ServerSetting.ReadTimeout = ServerSetting.ReadTimeout * time.Second
......@@ -82,7 +89,7 @@ func Setup() {
RedisSetting.IdleTimeout = RedisSetting.IdleTimeout * time.Second
}
// mapTo map section
//映射到配置文件的配置项
func mapTo(section string, v interface{}) {
err := cfg.Section(section).MapTo(v)
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