Skip to content

core(logger): add CV_LOG_ONCE_xxx() CV_LOG_IF_xxx() macros - #16704

Merged
alalek merged 2 commits into
opencv:3.4from
alalek:core_log_once_log_if
Mar 4, 2020
Merged

alalek merged 2 commits into
opencv:3.4from
alalek:core_log_once_log_if

Conversation

@alalek

@alalek alalek commented Mar 1, 2020

Copy link
Copy Markdown
Member

Added macros:

  • CV_LOG_ONCE_xxx(tag, ...message)
  • CV_LOG_IF_xxx(tag, logging_condition, ...message)

CV_LOG_VERBOSE(NULL, 0, "Verbose message: " << id);
CV_LOG_VERBOSE(NULL, 1, "Verbose message: " << id);
CV_LOG_DEBUG(NULL, "Debug message: " << id);
CV_LOG_INFO(NULL, "Info message: " << id);

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.

Google Test framework has 2 helper function to capture output: testing::internal::CaptureStdout and testing::internal::CaptureStderr. I would like to suggest to use the following pattern to check that message actually was logged:

    testing::internal::CaptureStdout();
    CV_LOG_INFO(NULL, "Info message: " << id);
    EXPECT_TRUE(testing::internal::GetCapturedStdout().find_first_of("Info message: 42") != std::string::npos);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thank you for the suggestion.

Actually I want to keep these tests as disabled for now - check compilation only (and run them in manual mode if we have corresponding changes).

@alalek

alalek commented Mar 4, 2020

Copy link
Copy Markdown
Member Author

👍

@alalek
alalek merged commit 4f288a1 into opencv:3.4 Mar 4, 2020
@alalek alalek mentioned this pull request Mar 4, 2020
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
* core(logger): add CV_LOG_ONCE_xxx() CV_LOG_IF_xxx() macros

* core(logger): keep tests disabled
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