remove use of any

This commit is contained in:
Darien Raymond
2016-10-16 14:22:21 +02:00
parent 5d9e6b0799
commit e33b7df34c
72 changed files with 728 additions and 792 deletions
-42
View File
@@ -1,42 +0,0 @@
package log
import (
"encoding/json"
"errors"
"strings"
)
func (this *Config) UnmarshalJSON(data []byte) error {
type JsonLogConfig struct {
AccessLog string `json:"access"`
ErrorLog string `json:"error"`
LogLevel string `json:"loglevel"`
}
jsonConfig := new(JsonLogConfig)
if err := json.Unmarshal(data, jsonConfig); err != nil {
return errors.New("Log: Failed to parse log config: " + err.Error())
}
if len(jsonConfig.AccessLog) > 0 {
this.AccessLogPath = jsonConfig.AccessLog
this.AccessLogType = LogType_File
}
if len(jsonConfig.ErrorLog) > 0 {
this.ErrorLogPath = jsonConfig.ErrorLog
this.ErrorLogType = LogType_File
}
level := strings.ToLower(jsonConfig.LogLevel)
switch level {
case "debug":
this.ErrorLogLevel = LogLevel_Debug
case "info":
this.ErrorLogLevel = LogLevel_Info
case "error":
this.ErrorLogLevel = LogLevel_Error
case "none":
this.ErrorLogType = LogType_None
default:
this.ErrorLogLevel = LogLevel_Warning
}
return nil
}