mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-01 01:44:15 +00: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:
parent
8320732743
commit
079d0bd8a9
291 changed files with 1837 additions and 2368 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue