utils/log: support max days of keeping log files

This commit is contained in:
fatedier
2016-05-03 21:41:57 +08:00
parent d7797cbd18
commit c10321ead6
8 changed files with 25 additions and 10 deletions

View File

@@ -28,6 +28,7 @@ var (
LogFile string = "console"
LogWay string = "console"
LogLevel string = "info"
LogMaxDays int64 = 3
HeartBeatInterval int64 = 20
HeartBeatTimeout int64 = 90
)
@@ -69,6 +70,11 @@ func LoadConf(confFile string) (err error) {
LogLevel = tmpStr
}
tmpStr, ok = conf.Get("common", "log_max_days")
if ok {
LogMaxDays, _ = strconv.ParseInt(tmpStr, 10, 64)
}
var authToken string
tmpStr, ok = conf.Get("common", "auth_token")
if ok {

View File

@@ -32,6 +32,7 @@ var (
LogFile string = "console"
LogWay string = "console" // console or file
LogLevel string = "info"
LogMaxDays int64 = 3
HeartBeatTimeout int64 = 90
UserConnTimeout int64 = 10
@@ -82,6 +83,11 @@ func LoadConf(confFile string) (err error) {
LogLevel = tmpStr
}
tmpStr, ok = conf.Get("common", "log_max_days")
if ok {
LogMaxDays, _ = strconv.ParseInt(tmpStr, 10, 64)
}
// servers
for name, section := range conf {
if name != "common" {

View File

@@ -113,8 +113,8 @@ func (p *ProxyServer) Start() (err error) {
// set timeout
time.AfterFunc(time.Duration(UserConnTimeout)*time.Second, func() {
p.Lock()
defer p.Unlock()
element := p.userConnList.Front()
p.Unlock()
if element == nil {
return
}