1
0

nop.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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) Start() error {
  13. return nil
  14. }
  15. func (f *nopFactory) Close() error {
  16. return nil
  17. }
  18. func (f *nopFactory) Level() Level {
  19. return LevelTrace
  20. }
  21. func (f *nopFactory) SetLevel(level Level) {
  22. }
  23. func (f *nopFactory) Logger() ContextLogger {
  24. return f
  25. }
  26. func (f *nopFactory) NewLogger(tag string) ContextLogger {
  27. return f
  28. }
  29. func (f *nopFactory) Trace(args ...any) {
  30. }
  31. func (f *nopFactory) Debug(args ...any) {
  32. }
  33. func (f *nopFactory) Info(args ...any) {
  34. }
  35. func (f *nopFactory) Warn(args ...any) {
  36. }
  37. func (f *nopFactory) Error(args ...any) {
  38. }
  39. func (f *nopFactory) Fatal(args ...any) {
  40. }
  41. func (f *nopFactory) Panic(args ...any) {
  42. }
  43. func (f *nopFactory) TraceContext(ctx context.Context, args ...any) {
  44. }
  45. func (f *nopFactory) DebugContext(ctx context.Context, args ...any) {
  46. }
  47. func (f *nopFactory) InfoContext(ctx context.Context, args ...any) {
  48. }
  49. func (f *nopFactory) WarnContext(ctx context.Context, args ...any) {
  50. }
  51. func (f *nopFactory) ErrorContext(ctx context.Context, args ...any) {
  52. }
  53. func (f *nopFactory) FatalContext(ctx context.Context, args ...any) {
  54. }
  55. func (f *nopFactory) PanicContext(ctx context.Context, args ...any) {
  56. }
  57. func (f *nopFactory) Subscribe() (subscription observable.Subscription[Entry], done <-chan struct{}, err error) {
  58. return nil, nil, os.ErrInvalid
  59. }
  60. func (f *nopFactory) UnSubscribe(subscription observable.Subscription[Entry]) {
  61. }