mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-07-25 09:14:23 -04:00
remove use of any
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user