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

Allow expressions in logging component parameters #3065

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

PeterBowman
Copy link
Member

@PeterBowman PeterBowman commented Dec 29, 2023

As shown in tests, this patch aims to enable the following syntax:

yCInfo(quiet ? LOG_COMPONENT_NULL : LOG_COMPONENT) << "message not shown if quiet=true";

Currently, due to macro expansion, the expression needs to be wrapped by an additional pair of parentheses:

yCInfo((quiet ? LOG_COMPONENT_NULL : LOG_COMPONENT)) << /* ... */;

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions

59.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@randaz81 randaz81 self-assigned this Jan 12, 2024
@randaz81 randaz81 self-requested a review January 12, 2024 11:23
@randaz81 randaz81 added this to the YARP 3.9.0 milestone Jan 12, 2024
@randaz81 randaz81 merged commit fbd36a6 into robotology:yarp-3.9 Jan 12, 2024
51 of 52 checks passed
@PeterBowman PeterBowman deleted the log-components-macro branch January 12, 2024 14:08
@PeterBowman
Copy link
Member Author

PeterBowman commented May 17, 2024

Hello, sorry for writing to a closed thread. Would it be possible to merge yarp-3.9 into master? In my code, I am doing something like this:

#if YARP_VERSION_COMPARE(>=, 3, 9, 0)
    yCInfo(quiet ? LC2 : LC) << "message";
#else
    yCInfo((quiet ? LC2 : LC)) << "message";
#endif

It fails on the master branch since this patch isn't included, yet in CMake it is stated that the current version is 3.9.0.

Besides, perhaps the current master could be always assigned the next minor version beforehand? That is, set it to 3.10.100 (the 100 denoting an unreleased version). I believe this is how it used to be some time ago, perhaps I missed the change. In this way, it would be possible to safely anticipate a new feature referring to the next version in an #if-guard such as the above one.

cc @randaz81

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants