std::format instead of snprintf in logger.cpp#4767
Open
yotam-medini wants to merge 6 commits intocanonical:mainfrom
Open
std::format instead of snprintf in logger.cpp#4767yotam-medini wants to merge 6 commits intocanonical:mainfrom
yotam-medini wants to merge 6 commits intocanonical:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Mir’s core logger timestamp formatting to use C++ std::format/std::chrono instead of snprintf-based char buffers, aligning with the direction in issue #4660.
Changes:
- Replace manual
timespec/strftime/snprintftimestamp construction withstd::chrono+std::format. - Add a fallback timestamp path when time zone formatting via
zoned_time/current_zone()fails. - Build a preformatted
"[timestamp] <severity>"prefix usingstd::format_to_n.
Contributor
AlanGriffiths
left a comment
There was a problem hiding this comment.
I know this idea originates from one of my comments, but I don't think that should be applied without regard to context.
Specifically, I'm not sure the change is well motivated here. The proposed code is harder to follow and adds complexity to widely used functionality. Is there anything it makes better?
Revert to UTC if current_zone() throws exception.
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.
Closes nothing
Related: #4660
Related to #4736
What's new?
std::format instead of snprintf in logger.cpp
How to test
Checklist