Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch logger to klog which is same as k8s system components #267

Merged
merged 2 commits into from
Mar 21, 2024

Conversation

lpdnju
Copy link
Contributor

@lpdnju lpdnju commented Mar 19, 2024

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"

@lpdnju lpdnju added the enhancement New feature or request label Mar 19, 2024
@lpdnju lpdnju force-pushed the user/peidlu/logger branch from 267f2d9 to 83ac7f0 Compare March 20, 2024 01:37
@zawachte zawachte merged commit b97f32c into master Mar 21, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants