2022-07-02 14:07:50 +08:00
|
|
|
package log
|
|
|
|
|
2022-07-20 09:41:44 +08:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"os"
|
2022-07-02 14:07:50 +08:00
|
|
|
|
2022-07-20 09:41:44 +08:00
|
|
|
"github.com/sagernet/sing/common/observable"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ ObservableFactory = (*nopFactory)(nil)
|
2022-07-02 14:07:50 +08:00
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
type nopFactory struct{}
|
2022-07-02 14:07:50 +08:00
|
|
|
|
2022-07-20 09:41:44 +08:00
|
|
|
func NewNOPFactory() ObservableFactory {
|
2022-07-12 15:17:29 +08:00
|
|
|
return (*nopFactory)(nil)
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
2023-12-04 11:47:25 +08:00
|
|
|
func (f *nopFactory) Start() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *nopFactory) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) Level() Level {
|
|
|
|
return LevelTrace
|
2022-07-03 01:57:04 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) SetLevel(level Level) {
|
2022-07-03 01:57:04 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) Logger() ContextLogger {
|
|
|
|
return f
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) NewLogger(tag string) ContextLogger {
|
|
|
|
return f
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) Trace(args ...any) {
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) Debug(args ...any) {
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) Info(args ...any) {
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) Warn(args ...any) {
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) Error(args ...any) {
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) Fatal(args ...any) {
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) Panic(args ...any) {
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) TraceContext(ctx context.Context, args ...any) {
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 15:17:29 +08:00
|
|
|
func (f *nopFactory) DebugContext(ctx context.Context, args ...any) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *nopFactory) InfoContext(ctx context.Context, args ...any) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *nopFactory) WarnContext(ctx context.Context, args ...any) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *nopFactory) ErrorContext(ctx context.Context, args ...any) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *nopFactory) FatalContext(ctx context.Context, args ...any) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *nopFactory) PanicContext(ctx context.Context, args ...any) {
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
2022-07-20 09:41:44 +08:00
|
|
|
|
|
|
|
func (f *nopFactory) Subscribe() (subscription observable.Subscription[Entry], done <-chan struct{}, err error) {
|
|
|
|
return nil, nil, os.ErrInvalid
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *nopFactory) UnSubscribe(subscription observable.Subscription[Entry]) {
|
|
|
|
}
|