switch logger to klog which is same as k8s system components #267
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Changes
switch logging library from zap to klog(same as k8s system components and capi. See: https://kubernetes.io/docs/concepts/cluster-administration/system-logs).
Using a consistent logging library across our entire system can simplify troubleshooting and parser/filter of logs.
Zap format:
<ISO 8601 timestamp> <log type> <log names> <message> { “<key1>”: “<values1>”, { “<key2>”: “<values2>”, ...}
Klog format:
<log type><klog timestamp> <log level> <log source>]> <log names> “msg”=”<message>” “<key1>”=”<value1>” “<key2>”=”<value2>” ...
Local test result:
Before:
2024-01-31T21:44:20Z INFO controllers.AzureStackHCIMachine Reconciling AzureStackHCIMachine {"azureStackHCIMachine": "default/justisun-tcl-2e105d9f-nodepool1-6797f64bd8-hz6wg", "reconcileID": "e6c70c30-1811-43e2-a302-6cf0b535372b", "operationId": "9229ecd1-0029-452f-85e4-6a482aa15374*2E280647B825D1C3F81F7550E2C1328DF7EE767E8DCE940E4783D7BF6BEB300C", "correlationId": "1bdfb35d-982f-4572-a9ab-dc0138bd827c", "machine": "justisun-tcl-2e105d9f-nodepool1-md-6cb66959bbxbh56g-j5hx2", "cluster": "justisun-tcl-2e105d9f", "azureStackHCICluster": "justisun-tcl-2e105d9f"}
After:
I0319 08:52:24.788606 1 azurestackhcimachine_controller.go:195] controllers/AzureStackHCIMachine "msg"="Reconciling AzureStackHCIMachine" "azureStackHCICluster"="peidlu-test-37a403e5" "azureStackHCIMachine"={"Namespace":"default","Name":"peidlu-test-37a403e5-control-plane-6qkw8"} "cluster"="peidlu-test-37a403e5" "correlationId"="904d6ee1-4607-4f17-9582-aa2f194e72c9" "machine"="peidlu-test-37a403e5-control-plane-rkc65" "operationId"="b486b04c-d2c4-40b0-8507-3a0bad424fb7*DBD477D6B9C29D03853E52C75CAED283A9C628B50C90809346BFB6FDB5102B6F" "reconcileID"="a45aef0d-e33f-4b10-8f13-f66d273eac63"