mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-30 23:37:44 +00:00
protobuf for log config
This commit is contained in:
8 files changed
+237
-71
No files matched your search
@@ -6,7 +6,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"v2ray.com/core/app/dns"
|
||||
"v2ray.com/core/app/router"
|
||||
@@ -24,7 +23,7 @@ const (
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
type JsonConfig struct {
|
||||
Port v2net.Port `json:"port"` // Port of this Point server.
|
||||
LogConfig *LogConfig `json:"log"`
|
||||
LogConfig *log.Config `json:"log"`
|
||||
RouterConfig *router.Config `json:"routing"`
|
||||
DNSConfig *dns.Config `json:"dns"`
|
||||
InboundConfig *InboundConnectionConfig `json:"inbound"`
|
||||
@@ -129,35 +128,6 @@ func (this *OutboundConnectionConfig) UnmarshalJSON(data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *LogConfig) 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("Point: Failed to parse log config: " + err.Error())
|
||||
}
|
||||
this.AccessLog = jsonConfig.AccessLog
|
||||
this.ErrorLog = jsonConfig.ErrorLog
|
||||
|
||||
level := strings.ToLower(jsonConfig.LogLevel)
|
||||
switch level {
|
||||
case "debug":
|
||||
this.LogLevel = log.DebugLevel
|
||||
case "info":
|
||||
this.LogLevel = log.InfoLevel
|
||||
case "error":
|
||||
this.LogLevel = log.ErrorLevel
|
||||
case "none":
|
||||
this.LogLevel = log.NoneLevel
|
||||
default:
|
||||
this.LogLevel = log.WarningLevel
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *InboundDetourAllocationConfig) UnmarshalJSON(data []byte) error {
|
||||
type JsonInboundDetourAllocationConfig struct {
|
||||
Strategy string `json:"strategy"`
|
||||
|
||||
Reference in new issue
Block a user