log.go 609 B

123456789101112131415161718192021222324252627282930
  1. package log
  2. import (
  3. "context"
  4. "github.com/sagernet/sing-box/option"
  5. )
  6. type Logger interface {
  7. Start() error
  8. Close() error
  9. Trace(args ...interface{})
  10. Debug(args ...interface{})
  11. Info(args ...interface{})
  12. Print(args ...interface{})
  13. Warn(args ...interface{})
  14. Warning(args ...interface{})
  15. Error(args ...interface{})
  16. Fatal(args ...interface{})
  17. Panic(args ...interface{})
  18. WithContext(ctx context.Context) Logger
  19. WithPrefix(prefix string) Logger
  20. }
  21. func NewLogger(options option.LogOption) (Logger, error) {
  22. if options.Disabled {
  23. return NewNopLogger(), nil
  24. }
  25. return NewLogrusLogger(options)
  26. }