refactor(i18n): enrich service state snapshot
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
852b11fda5
commit
730b6166a1
2 changed files with 15 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
15
state.go
15
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, "<nil>")
|
||||
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,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue