MCPcopy
hub / github.com/gofiber/fiber / logServices

Method logServices

services.go:147–176  ·  view source on GitHub ↗

logServices logs information about services and returns an error if any configured service is nil.

(ctx context.Context, out io.Writer, colors *Colors)

Source from the content-addressed store, hash-verified

145// logServices logs information about services and returns an error
146// if any configured service is nil.
147func (app *App) logServices(ctx context.Context, out io.Writer, colors *Colors) error {
148 if !app.hasConfiguredServices() {
149 return nil
150 }
151
152 scheme := colors
153 if scheme == nil {
154 scheme = &DefaultColors
155 }
156
157 fmt.Fprintf(out,
158 "%sINFO%s Services: \t%s%d%s\n",
159 scheme.Green, scheme.Reset, scheme.Blue, app.state.ServicesLen(), scheme.Reset)
160 for key, srv := range app.state.Services() {
161 if srv == nil {
162 return fmt.Errorf("fiber: service %q is nil", key)
163 }
164 var state string
165 var stateColor string
166 state, err := srv.State(ctx)
167 if err != nil {
168 state = errString
169 stateColor = scheme.Red
170 } else {
171 stateColor = scheme.Blue
172 }
173 fmt.Fprintf(out, "%sINFO%s 🧩 %s[ %s ] %s%s\n", scheme.Green, scheme.Reset, stateColor, utilsstrings.ToUpper(state), srv.String(), scheme.Reset)
174 }
175 return nil
176}

Callers 2

startupMessageMethod · 0.95
Test_LogServicesFunction · 0.95

Calls 6

hasConfiguredServicesMethod · 0.95
ServicesLenMethod · 0.80
ServicesMethod · 0.80
ErrorfMethod · 0.65
StateMethod · 0.65
StringMethod · 0.65

Tested by 1

Test_LogServicesFunction · 0.76