| 516 | } |
| 517 | |
| 518 | func (w *LinePrefixLogger) Write(p []byte) (n int, err error) { |
| 519 | for line := range strings.SplitSeq(string(p), "\n") { |
| 520 | // Skip empty lines |
| 521 | line = strings.TrimSpace(line) |
| 522 | if line == "" { |
| 523 | continue |
| 524 | } |
| 525 | |
| 526 | // Write the prefix + line to the wrapped writer |
| 527 | if err := w.logger.Log(w.prefix + line); err != nil { |
| 528 | return 0, err |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | return len(p), nil |
| 533 | } |
| 534 | |
| 535 | // HTTPService represents opinionated microservice with at least HTTP port that as mandatory requirement, |
| 536 | // serves metrics. |