Files
free-turn-proxy-orig/internal/logx/logx.go
T
samosvalishe ed6825976a fix: исправить баги, sentinel-ошибки, устаревшие доки
Баги:
- udprelay: errors.Is(DeadlineExceeded) вместо сравнения строк; короткий
  backoff в ветке lockout; обернуть DTLS-ошибку через %w
- bondserver.copyBondToBackend: лимит pending-map в 1024 (паритет с bondclient)
- srtpmimicry.RelayPacketConn: bufPool для горячего UDP-пути (паритет с listen.go)
- vkauth.token.go: ручной солвер под ctx.WithTimeout(ctx, ...) вместо Background
  — нет утечки горутины при shutdown

Гигиена:
- sentinel-ошибки vkauth как var = errors.New(...); вызыватели используют errors.Is
- убраны устаревшие комментарии этапов рефакторинга (Pion SPDX, "Package bond",
  internal/bond, удалённый файл заметок)
- .gitignore: *.exe, *.so

Тесты + lint проходят.
2026-05-19 21:47:48 +03:00

51 lines
1.7 KiB
Go

// Package logx is a minimal leveled logger over stdlib log. Callers receive a
// Logger and call Debugf/Infof/Warnf/Errorf directly; Debugf is gated by a
// debug flag, the other levels always print via stdlib log.
package logx
import "log"
// Logger is the leveled-log interface used across the proxy. Debugf is gated by
// the constructor's debug flag; the other levels always print via stdlib log.
type Logger interface {
Debugf(format string, v ...any)
Infof(format string, v ...any)
Warnf(format string, v ...any)
Errorf(format string, v ...any)
// DebugEnabled reports whether Debugf will produce output. Hot paths
// (stats counters, condition-gated branches) use this to skip work the
// logger would discard anyway.
DebugEnabled() bool
}
type stdLogger struct {
debug bool
}
// New returns a Logger that prints via stdlib log. If debug is false, Debugf is
// a no-op.
func New(debug bool) Logger {
return &stdLogger{debug: debug}
}
// Nop returns a Logger whose every method discards its input. Useful in tests.
func Nop() Logger { return nopLogger{} }
func (l *stdLogger) Debugf(format string, v ...any) {
if l.debug {
log.Printf(format, v...)
}
}
func (l *stdLogger) Infof(format string, v ...any) { log.Printf(format, v...) }
func (l *stdLogger) Warnf(format string, v ...any) { log.Printf(format, v...) }
func (l *stdLogger) Errorf(format string, v ...any) { log.Printf(format, v...) }
func (l *stdLogger) DebugEnabled() bool { return l.debug }
type nopLogger struct{}
func (nopLogger) Debugf(string, ...any) {}
func (nopLogger) Infof(string, ...any) {}
func (nopLogger) Warnf(string, ...any) {}
func (nopLogger) Errorf(string, ...any) {}
func (nopLogger) DebugEnabled() bool { return false }