nop.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package log
  2. import (
  3. "context"
  4. "os"
  5. "github.com/sagernet/sing/common/observable"
  6. )
  7. var _ ObservableFactory = (*nopFactory)(nil)
  8. type nopFactory struct{}
  9. func NewNOPFactory() ObservableFactory {
  10. return (*nopFactory)(nil)
  11. }
  12. func (f *nopFactory) Level() Level {
  13. return LevelTrace
  14. }
  15. func (f *nopFactory) SetLevel(level Level) {
  16. }
  17. func (f *nopFactory) Logger() ContextLogger {
  18. return f
  19. }
  20. func (f *nopFactory) NewLogger(tag string) ContextLogger {
  21. return f
  22. }
  23. func (f *nopFactory) Trace(args ...any) {
  24. }
  25. func (f *nopFactory) Debug(args ...any) {
  26. }
  27. func (f *nopFactory) Info(args ...any) {
  28. }
  29. func (f *nopFactory) Warn(args ...any) {
  30. }
  31. func (f *nopFactory) Error(args ...any) {
  32. }
  33. func (f *nopFactory) Fatal(args ...any) {
  34. }
  35. func (f *nopFactory) Panic(args ...any) {
  36. }
  37. func (f *nopFactory) TraceContext(ctx context.Context, args ...any) {
  38. }
  39. func (f *nopFactory) DebugContext(ctx context.Context, args ...any) {
  40. }
  41. func (f *nopFactory) InfoContext(ctx context.Context, args ...any) {
  42. }
  43. func (f *nopFactory) WarnContext(ctx context.Context, args ...any) {
  44. }
  45. func (f *nopFactory) ErrorContext(ctx context.Context, args ...any) {
  46. }
  47. func (f *nopFactory) FatalContext(ctx context.Context, args ...any) {
  48. }
  49. func (f *nopFactory) PanicContext(ctx context.Context, args ...any) {
  50. }
  51. func (f *nopFactory) Subscribe() (subscription observable.Subscription[Entry], done <-chan struct{}, err error) {
  52. return nil, nil, os.ErrInvalid
  53. }
  54. func (f *nopFactory) UnSubscribe(subscription observable.Subscription[Entry]) {
  55. }