mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-12 22:38:15 +03:00
Refactor log
This commit is contained in:
45
log/factory.go
Normal file
45
log/factory.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/sagernet/sing/common/observable"
|
||||
)
|
||||
|
||||
type Factory interface {
|
||||
Level() Level
|
||||
SetLevel(level Level)
|
||||
Logger() ContextLogger
|
||||
NewLogger(tag string) ContextLogger
|
||||
}
|
||||
|
||||
type ObservableFactory interface {
|
||||
Factory
|
||||
observable.Observable[Entry]
|
||||
}
|
||||
|
||||
type Entry struct {
|
||||
Level Level
|
||||
Message string
|
||||
}
|
||||
|
||||
type Logger interface {
|
||||
Trace(args ...any)
|
||||
Debug(args ...any)
|
||||
Info(args ...any)
|
||||
Warn(args ...any)
|
||||
Error(args ...any)
|
||||
Fatal(args ...any)
|
||||
Panic(args ...any)
|
||||
}
|
||||
|
||||
type ContextLogger interface {
|
||||
Logger
|
||||
TraceContext(ctx context.Context, args ...any)
|
||||
DebugContext(ctx context.Context, args ...any)
|
||||
InfoContext(ctx context.Context, args ...any)
|
||||
WarnContext(ctx context.Context, args ...any)
|
||||
ErrorContext(ctx context.Context, args ...any)
|
||||
FatalContext(ctx context.Context, args ...any)
|
||||
PanicContext(ctx context.Context, args ...any)
|
||||
}
|
||||
Reference in New Issue
Block a user