factory.go 881 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package log
  2. import (
  3. "context"
  4. "github.com/sagernet/sing/common/observable"
  5. )
  6. type Factory interface {
  7. Level() Level
  8. SetLevel(level Level)
  9. Logger() ContextLogger
  10. NewLogger(tag string) ContextLogger
  11. }
  12. type ObservableFactory interface {
  13. Factory
  14. observable.Observable[Entry]
  15. }
  16. type Entry struct {
  17. Level Level
  18. Message string
  19. }
  20. type Logger interface {
  21. Trace(args ...any)
  22. Debug(args ...any)
  23. Info(args ...any)
  24. Warn(args ...any)
  25. Error(args ...any)
  26. Fatal(args ...any)
  27. Panic(args ...any)
  28. }
  29. type ContextLogger interface {
  30. Logger
  31. TraceContext(ctx context.Context, args ...any)
  32. DebugContext(ctx context.Context, args ...any)
  33. InfoContext(ctx context.Context, args ...any)
  34. WarnContext(ctx context.Context, args ...any)
  35. ErrorContext(ctx context.Context, args ...any)
  36. FatalContext(ctx context.Context, args ...any)
  37. PanicContext(ctx context.Context, args ...any)
  38. }