Skip to content

Commit 1a09f12

Browse files
Add log message style guidelines
1 parent 3411950 commit 1a09f12

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

contributors/devel/sig-instrumentation/logging.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ Example:
4848
klog.InfoS("Received HTTP request", "method", "GET", "URL", "/metrics", "latency", time.Second)
4949
```
5050

51+
### Message style guidelines
52+
53+
Good practices when writing log messages are:
54+
55+
- Start from a capital letter.
56+
- Do not end the message with a period.
57+
- Use active voice. Use complete sentences when there is an acting subject ("A could not do B") or omit the subject if the subject would be the program itself ("Could not do B").
58+
- Use past tense ("Could not delete B" instead of "Cannot delete B")
59+
- When referring to an object, state what type of object it is. ("Deleted pod" instead of "Deleted")
60+
5161
### What method to use?
5262

5363
* `klog.ErrorS` - Errors should be used to indicate unexpected behaviours in code, like unexpected errors returned by subroutine function calls.

0 commit comments

Comments
 (0)