{{ message }}
logger: improve format of timestamp (quality of life improvement)#7355
Merged
rbradford merged 2 commits intocloud-hypervisor:mainfrom Sep 22, 2025
Merged
Conversation
Streamline the output format of the timestamp of a message. The old format doesn't nicely align across multiple lines. # Example (old style) ``` cloud-hypervisor: 858.465660ms: <vcpu0> DEBUG:devices/src/ioapic.rs:154 -- IOAPIC_R @ offset 0x10 cloud-hypervisor: 858.507342ms: <vcpu0> DEBUG:devices/src/ioapic.rs:298 -- IOAPIC_R reg 0x1 cloud-hypervisor: 1.010001s: <vcpu0> DEBUG:devices/src/ioapic.rs:174 -- IOAPIC_W @ offset 0x0 cloud-hypervisor: 1.010067s: <vcpu0> DEBUG:devices/src/ioapic.rs:154 -- IOAPIC_R @ offset 0x10 ``` # Example (new style) ``` cloud-hypervisor: 0.731399s: <vcpu0> DEBUG:devices/src/ioapic.rs:174 -- IOAPIC_W @ offset 0x10 cloud-hypervisor: 0.731420s: <vcpu0> DEBUG:devices/src/ioapic.rs:252 -- IOAPIC_W reg 0x2a, val 0x10000 cloud-hypervisor: 17.026073s: <vmm> INFO:vmm/src/api/mod.rs:898 -- API request event: VmInfo cloud-hypervisor: 17.263210s: <vmm> INFO:vmm/src/api/mod.rs:898 -- API request event: VmInfo cloud-hypervisor: 17.547915s: <vmm> INFO:vmm/src/api/mod.rs:898 -- API request event: VmInfo ``` Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de> On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de> On-behalf-of: SAP philipp.schuster@sap.com
Contributor
Member
Author
Could you please elaborate a little about the value-add you see in this behavior? IMHO, having things aligned helps humans to parse the log much faster. And you have the milliseconds anyway, just in an aligned format. |
up2wing
reviewed
Sep 17, 2025
|
|
||
| let now = std::time::Instant::now(); | ||
| let duration = now.duration_since(self.start); | ||
| let duration_s = duration.as_secs_f32(); |
Contributor
There was a problem hiding this comment.
This looks better:
let duration = self.start.elapsed().as_secs_f32();
Member
|
Thanks @phip1611 - although this looks nice - I worry that this might break tooling that expects only a single space before the time - I see from the format string it right aligns it to 10 characters? How is that going to look when a VM is up for many months or even years? |
Member
Author
rbradford
approved these changes
Sep 22, 2025
Merged
via the queue into
cloud-hypervisor:main
with commit Sep 22, 2025
fae3241
42 of 44 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

This is a small improvement to the timestamp in the logging format.
Example (old style)
Example (new style)