Skip to content

#20: Allow string args in log template function#21

Merged
chadalon merged 2 commits intodevelopfrom
20-allow-for-formatting-strings
Feb 5, 2026
Merged

#20: Allow string args in log template function#21
chadalon merged 2 commits intodevelopfrom
20-allow-for-formatting-strings

Conversation

@chadalon
Copy link
Copy Markdown
Contributor

I simply removed the std::to_string() call when printing out the arguments given an error. The ostringstream << operator already handles strings, numeric types, and most other types, so we don't need to convert the args anyway.

@chadalon chadalon linked an issue Jan 19, 2026 that may be closed by this pull request
@chadalon chadalon requested a review from cwschilly January 19, 2026 22:52
Copy link
Copy Markdown
Contributor

@cwschilly cwschilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; just requesting some changes to the unit test to simplify and confirm everything works

#include "LoggerTest.hpp"
#include "pressio-log/core.hpp"

TEST_F(LoggerTest, Logger_String_Templated) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we test the individual log levels in a separate unit test, we don't need to run through them all here (they all call the same logging function, so if the formatting works for one, it'll work for them all).

Just pick one level (i.e. SPARSE) and run through some of the permutations you have here (one string, two strings, number and a string).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this to use sparse level for each log.

@chadalon chadalon merged commit 89ef48d into develop Feb 5, 2026
4 checks passed
@chadalon chadalon deleted the 20-allow-for-formatting-strings branch February 5, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow for formatting strings

2 participants