mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-13 11:59:35 +03:00
Refactor log (#3446)
* Refactor log * Add new log methods * Fix logger test * Change all logging code * Clean up pathObj * Rebase to latest main * Remove invoking method name after the dot
This commit is contained in:
@ -61,9 +61,9 @@ func DecodeJSONConfig(reader io.Reader) (*conf.Config, error) {
|
||||
pos = findOffset(jsonContent.Bytes(), int(tErr.Offset))
|
||||
}
|
||||
if pos != nil {
|
||||
return nil, newError("failed to read config file at line ", pos.line, " char ", pos.char).Base(err)
|
||||
return nil, errors.New("failed to read config file at line ", pos.line, " char ", pos.char).Base(err)
|
||||
}
|
||||
return nil, newError("failed to read config file").Base(err)
|
||||
return nil, errors.New("failed to read config file").Base(err)
|
||||
}
|
||||
|
||||
return jsonConfig, nil
|
||||
@ -77,7 +77,7 @@ func LoadJSONConfig(reader io.Reader) (*core.Config, error) {
|
||||
|
||||
pbConfig, err := jsonConfig.Build()
|
||||
if err != nil {
|
||||
return nil, newError("failed to parse json config").Base(err)
|
||||
return nil, errors.New("failed to parse json config").Base(err)
|
||||
}
|
||||
|
||||
return pbConfig, nil
|
||||
@ -88,17 +88,17 @@ func LoadJSONConfig(reader io.Reader) (*core.Config, error) {
|
||||
func DecodeTOMLConfig(reader io.Reader) (*conf.Config, error) {
|
||||
tomlFile, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
return nil, newError("failed to read config file").Base(err)
|
||||
return nil, errors.New("failed to read config file").Base(err)
|
||||
}
|
||||
|
||||
configMap := make(map[string]interface{})
|
||||
if err := toml.Unmarshal(tomlFile, &configMap); err != nil {
|
||||
return nil, newError("failed to convert toml to map").Base(err)
|
||||
return nil, errors.New("failed to convert toml to map").Base(err)
|
||||
}
|
||||
|
||||
jsonFile, err := json.Marshal(&configMap)
|
||||
if err != nil {
|
||||
return nil, newError("failed to convert map to json").Base(err)
|
||||
return nil, errors.New("failed to convert map to json").Base(err)
|
||||
}
|
||||
|
||||
return DecodeJSONConfig(bytes.NewReader(jsonFile))
|
||||
@ -112,7 +112,7 @@ func LoadTOMLConfig(reader io.Reader) (*core.Config, error) {
|
||||
|
||||
pbConfig, err := tomlConfig.Build()
|
||||
if err != nil {
|
||||
return nil, newError("failed to parse toml config").Base(err)
|
||||
return nil, errors.New("failed to parse toml config").Base(err)
|
||||
}
|
||||
|
||||
return pbConfig, nil
|
||||
@ -123,12 +123,12 @@ func LoadTOMLConfig(reader io.Reader) (*core.Config, error) {
|
||||
func DecodeYAMLConfig(reader io.Reader) (*conf.Config, error) {
|
||||
yamlFile, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
return nil, newError("failed to read config file").Base(err)
|
||||
return nil, errors.New("failed to read config file").Base(err)
|
||||
}
|
||||
|
||||
jsonFile, err := yaml.YAMLToJSON(yamlFile)
|
||||
if err != nil {
|
||||
return nil, newError("failed to convert yaml to json").Base(err)
|
||||
return nil, errors.New("failed to convert yaml to json").Base(err)
|
||||
}
|
||||
|
||||
return DecodeJSONConfig(bytes.NewReader(jsonFile))
|
||||
@ -142,7 +142,7 @@ func LoadYAMLConfig(reader io.Reader) (*core.Config, error) {
|
||||
|
||||
pbConfig, err := yamlConfig.Build()
|
||||
if err != nil {
|
||||
return nil, newError("failed to parse yaml config").Base(err)
|
||||
return nil, errors.New("failed to parse yaml config").Base(err)
|
||||
}
|
||||
|
||||
return pbConfig, nil
|
||||
|
Reference in New Issue
Block a user