@@ -19,6 +19,8 @@ In Cluster API we strive to follow three principles while implementing logging:
1919Kubernetes defines a set of [ logging conventions] ( https://git.k8s.io/community/contributors/devel/sig-instrumentation/logging.md ) ,
2020as well as tools and libraries for logging.
2121
22+ Cluster API should align to those guidelines and use those tools as much as possible.
23+
2224## Continuous improvement
2325
2426The foundational items of Cluster API logging are:
@@ -100,6 +102,11 @@ key value pairs (in order of importance):
100102 creates a MachineSet.
101103- Other Key value pairs.
102104
105+ Notably, over time in CAPI we are also standardizing usage of other key value pairs to improve consistency when reading
106+ logs, e.g.
107+ - key ` reason ` MUST be used when adding details about WHY a change happened.
108+ - key ` diff ` MUST be used when documenting the diff in an object that either lead to a chance, or that is resulting from a change.
109+
103110## Log Messages
104111
105112- A Message MUST always start with a capital letter.
@@ -108,7 +115,13 @@ key value pairs (in order of importance):
108115 the action log and the corresponding error log; While logging before the action, log verbs should use the -ing form.
109116- Ideally log messages should surface a different level of detail according to the target log level (see [ log levels] ( #log-levels )
110117 for more details).
111- - If Kubernetes resource name is used in log messages, it should be used as is, For example ` Reconciling DockerMachineTemplate `
118+ - If Kubernetes resource name is used in log messages, it MUST be used as is, For example ` Reconciling DockerMachineTemplate `
119+ - If an API field name is used in log messages, the entire path MUST be used and field names MUST capitalized like in the
120+ API (not as in the golang type). For example ` Waiting for spec.providerID to be set `
121+ - If a log messages about a controlled or a referenced object, e.g. Machine controller performing an action on MachineSet,
122+ the message MUST contain the Kind of the controlled/referenced object and its name, for example ` Created MachineSet foo-bar `
123+ - If the controlled/referenced object is in another namespace, use namespace/name instead of name
124+ - The controlled/referenced MUST also be added as a key value pair (see guidelines above)
112125
113126## Log Levels
114127
0 commit comments