go-i18n/debug.go
Virgil 99412a64ea
All checks were successful
Security Scan / security (push) Successful in 25s
Test / test (push) Successful in 1m20s
fix(i18n): make service nil-safe
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 14:02:13 +00:00

30 lines
544 B
Go

package i18n
import "dappco.re/go/core"
// SetDebug enables or disables debug mode on the default service.
func SetDebug(enabled bool) {
withDefaultService(func(svc *Service) { svc.SetDebug(enabled) })
}
func (s *Service) SetDebug(enabled bool) {
if s == nil {
return
}
s.mu.Lock()
defer s.mu.Unlock()
s.debug = enabled
}
func (s *Service) Debug() bool {
if s == nil {
return false
}
s.mu.RLock()
defer s.mu.RUnlock()
return s.debug
}
func debugFormat(key, text string) string {
return core.Sprintf("[%s] %s", key, text)
}