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

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

Merged
merged 2 commits into from Mar 4, 2020

Conversation

alalek
Copy link
Member

@alalek alalek commented Mar 1, 2020

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
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
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
Copy link
Member Author

alalek commented Mar 4, 2020

👍

@alalek alalek merged commit 4f288a1 into opencv:3.4 Mar 4, 2020
@alalek alalek mentioned this pull request Mar 4, 2020
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.

None yet

2 participants