/
nekstep
/
gvcli
Обзор
Документация
Войти
/
nekstep
/
gvcli
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
internal/debug/logger.go
56 строк
1 KB
Oleg Chirukhin
refactoring: huge UI changes
18 июл 2025, 07:16
18 июл 2025, 07:16
ed0c8cb
Код
Авторство
О чём код?
package debug import ( "fmt" "log" ) // Logger handles debug logging // Use for all debug, password, and HTTP debug output type Logger struct { enabled bool passwordsEnabled bool httpEnabled bool } func NewLogger(enabled, passwordsEnabled, httpEnabled bool) *Logger { return &Logger{ enabled: enabled, passwordsEnabled: passwordsEnabled, httpEnabled: httpEnabled, } } func (l *Logger) Debug(format string, args ...interface{}) { if l.enabled { log.Printf(format, args...) } } func (l *Logger) DebugHTTP(format string, args ...interface{}) { if l.httpEnabled { log.Printf("[DEBUG_HTTP] "+format, args...) } } func (l *Logger) MaskToken(token string) string { if l.passwordsEnabled { return token } if len(token) > 8 { return token[:4] + "****" + token[len(token)-4:] } return "****" } func (l *Logger) LogTokenBytes(token string) { if l.enabled { fmt.Printf("[DEBUG] JWT token bytes: %v\n", []byte(token)) for i, b := range []byte(token) { if b < 32 || b == 127 { fmt.Printf("[DEBUG] WARNING: Non-printable or whitespace character (byte %d: %d) in token!\n", i, b) } } } }