logServices logs information about services and returns an error if any configured service is nil.
(ctx context.Context, out io.Writer, colors *Colors)
| 145 | // logServices logs information about services and returns an error |
| 146 | // if any configured service is nil. |
| 147 | func (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 | } |