From 730b6166a1c677c3b0014905451277f380a281c0 Mon Sep 17 00:00:00 2001 From: Virgil Date: Thu, 2 Apr 2026 13:02:28 +0000 Subject: [PATCH] refactor(i18n): enrich service state snapshot Co-Authored-By: Virgil --- service_test.go | 1 + state.go | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/service_test.go b/service_test.go index 24730a3..c0598dd 100644 --- a/service_test.go +++ b/service_test.go @@ -253,6 +253,7 @@ func TestServiceStateString(t *testing.T) { "mode=", "available=", "handlers=", + "LabelHandler", } { if !strings.Contains(got, want) { t.Fatalf("ServiceState.String() = %q, want substring %q", got, want) diff --git a/state.go b/state.go index bb18608..d1b53ca 100644 --- a/state.go +++ b/state.go @@ -25,8 +25,20 @@ func (s ServiceState) String() string { if len(s.AvailableLanguages) > 0 { langs = "[" + core.Join(", ", s.AvailableLanguages...) + "]" } + handlers := "[]" + if len(s.Handlers) > 0 { + names := make([]string, 0, len(s.Handlers)) + for _, handler := range s.Handlers { + if handler == nil { + names = append(names, "") + continue + } + names = append(names, core.Sprintf("%T", handler)) + } + handlers = "[" + core.Join(", ", names...) + "]" + } return core.Sprintf( - "ServiceState{language=%q fallback=%q mode=%s formality=%s location=%q direction=%s rtl=%t debug=%t available=%s handlers=%d}", + "ServiceState{language=%q fallback=%q mode=%s formality=%s location=%q direction=%s rtl=%t debug=%t available=%s handlers=%d types=%s}", s.Language, s.Fallback, s.Mode, @@ -37,6 +49,7 @@ func (s ServiceState) String() string { s.Debug, langs, len(s.Handlers), + handlers, ) }