logger.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package singbridge
  2. import (
  3. "context"
  4. "github.com/sagernet/sing/common/logger"
  5. "github.com/xtls/xray-core/common/errors"
  6. )
  7. var _ logger.ContextLogger = (*XrayLogger)(nil)
  8. type XrayLogger struct {
  9. newError func(values ...any) *errors.Error
  10. }
  11. func NewLogger(newErrorFunc func(values ...any) *errors.Error) *XrayLogger {
  12. return &XrayLogger{
  13. newErrorFunc,
  14. }
  15. }
  16. func (l *XrayLogger) Trace(args ...any) {
  17. }
  18. func (l *XrayLogger) Debug(args ...any) {
  19. errors.LogDebug(context.Background(), args...)
  20. }
  21. func (l *XrayLogger) Info(args ...any) {
  22. errors.LogInfo(context.Background(), args...)
  23. }
  24. func (l *XrayLogger) Warn(args ...any) {
  25. errors.LogWarning(context.Background(), args...)
  26. }
  27. func (l *XrayLogger) Error(args ...any) {
  28. errors.LogError(context.Background(), args...)
  29. }
  30. func (l *XrayLogger) Fatal(args ...any) {
  31. }
  32. func (l *XrayLogger) Panic(args ...any) {
  33. }
  34. func (l *XrayLogger) TraceContext(ctx context.Context, args ...any) {
  35. }
  36. func (l *XrayLogger) DebugContext(ctx context.Context, args ...any) {
  37. errors.LogDebug(ctx, args...)
  38. }
  39. func (l *XrayLogger) InfoContext(ctx context.Context, args ...any) {
  40. errors.LogInfo(ctx, args...)
  41. }
  42. func (l *XrayLogger) WarnContext(ctx context.Context, args ...any) {
  43. errors.LogWarning(ctx, args...)
  44. }
  45. func (l *XrayLogger) ErrorContext(ctx context.Context, args ...any) {
  46. errors.LogError(ctx, args...)
  47. }
  48. func (l *XrayLogger) FatalContext(ctx context.Context, args ...any) {
  49. }
  50. func (l *XrayLogger) PanicContext(ctx context.Context, args ...any) {
  51. }