Maintain consistent formatting conventions across log messages to improve code readability and debugging effectiveness. Use proper format specifiers (%v for errors, not %s), maintain consistent spacing around punctuation (no spaces before colons), and ensure consistent label semantics when logging similar data structures.
Key formatting guidelines:
%v
format specifier for error values instead of %s
Example of good formatting:
// Good - consistent formatting, proper specifier
log.Infof("connection closed: %v", err)
log.WithLabels("removes", len(resp.RemovedResources)).Debugf("forward ECDS")
// Bad - inconsistent spacing, wrong specifier, redundant text
log.Infof("connection is not closed with error : %s", err)
log.WithLabels("removals", resp.RemovedResources).Debugf("forward ECDS")
This consistency helps maintain professional code quality and makes log analysis more predictable for debugging and monitoring.
Enter the URL of a public GitHub repository