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:
yuhan6665 2024-06-29 14:32:57 -04:00 committed by GitHub
parent 8320732743
commit 079d0bd8a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
291 changed files with 1837 additions and 2368 deletions

View file

@ -1,8 +1,10 @@
package serial
import (
"context"
"io"
"github.com/xtls/xray-core/common/errors"
creflect "github.com/xtls/xray-core/common/reflect"
"github.com/xtls/xray-core/core"
"github.com/xtls/xray-core/infra/conf"
@ -18,20 +20,20 @@ func MergeConfigFromFiles(files []string, formats []string) (string, error) {
if j, ok := creflect.MarshalToJson(c); ok {
return j, nil
}
return "", newError("marshal to json failed.").AtError()
return "", errors.New("marshal to json failed.").AtError()
}
func mergeConfigs(files []string, formats []string) (*conf.Config, error) {
cf := &conf.Config{}
for i, file := range files {
newError("Reading config: ", file).AtInfo().WriteToLog()
errors.LogInfo(context.Background(), "Reading config: ", file)
r, err := confloader.LoadConfig(file)
if err != nil {
return nil, newError("failed to read config: ", file).Base(err)
return nil, errors.New("failed to read config: ", file).Base(err)
}
c, err := ReaderDecoderByFormat[formats[i]](r)
if err != nil {
return nil, newError("failed to decode config: ", file).Base(err)
return nil, errors.New("failed to decode config: ", file).Base(err)
}
if i == 0 {
*cf = *c