mirror of https://github.com/XTLS/Xray-core
Browse Source
* 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 dotpull/3485/head
yuhan6665
5 months ago
committed by
GitHub
291 changed files with 1837 additions and 2368 deletions
@ -1,9 +0,0 @@
|
||||
package commander |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package dispatcher |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package dns |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package fakedns |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package command |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package log |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package metrics |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package burst |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package observatory |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package policy |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package command |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package inbound |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package outbound |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package reverse |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package command |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package router |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package command |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package stats |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package buf |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package crypto |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -0,0 +1,25 @@
|
||||
package ctx |
||||
|
||||
import "context" |
||||
|
||||
type SessionKey int |
||||
|
||||
// ID of a session.
|
||||
type ID uint32 |
||||
|
||||
const( |
||||
idSessionKey SessionKey = 0 |
||||
) |
||||
|
||||
// ContextWithID returns a new context with the given ID.
|
||||
func ContextWithID(ctx context.Context, id ID) context.Context { |
||||
return context.WithValue(ctx, idSessionKey, id) |
||||
} |
||||
|
||||
// IDFromContext returns ID in this context, or 0 if not contained.
|
||||
func IDFromContext(ctx context.Context) ID { |
||||
if id, ok := ctx.Value(idSessionKey).(ID); ok { |
||||
return id |
||||
} |
||||
return 0 |
||||
} |
@ -1,9 +0,0 @@
|
||||
package drain |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package common |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,37 +0,0 @@
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"os" |
||||
"path/filepath" |
||||
) |
||||
|
||||
func main() { |
||||
pwd, err := os.Getwd() |
||||
if err != nil { |
||||
fmt.Println("can not get current working directory") |
||||
os.Exit(1) |
||||
} |
||||
pkg := filepath.Base(pwd) |
||||
if pkg == "xray-core" { |
||||
pkg = "core" |
||||
} |
||||
|
||||
file, err := os.OpenFile("errors.generated.go", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0o644) |
||||
if err != nil { |
||||
fmt.Printf("Failed to generate errors.generated.go: %v", err) |
||||
os.Exit(1) |
||||
} |
||||
defer file.Close() |
||||
|
||||
fmt.Fprintf(file, `package %s |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
||||
`, pkg) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package mux |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package net |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package ocsp |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package ctlcmd |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package dns |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
@ -1,9 +0,0 @@
|
||||
package protocol |
||||
|
||||
import "github.com/xtls/xray-core/common/errors" |
||||
|
||||
type errPathObjHolder struct{} |
||||
|
||||
func newError(values ...interface{}) *errors.Error { |
||||
return errors.New(values...).WithPathObj(errPathObjHolder{}) |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue