Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

User-defined logger callback, C-style.#27154

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@kinchungwong
Copy link
Contributor

@kinchungwongkinchungwong commentedMar 26, 2025
edited
Loading

This is a competing PR, an alternative to#27140

Both functions accept C-style pointer to static functions. Both functions allow restoring the OpenCV built-in implementation by passing in a nullptr.

  • replaceWriteLogMessage
  • replaceWriteLogMessageEx

This implementation is not compatible with C++ log handler objects.

This implementation has minimal thread safety, in the sense that the function pointer are stored and read atomically. But otherwise, the user-defined static functions must accept calls at all times, even after having been deregistered, because some log calls may have started before deregistering.

Pull Request Readiness Checklist

See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

opencv-alalek reacted with thumbs up emoji
Both functions accept C-style pointer to static functions.Both functions allow restoring the OpenCV built-in implementation by passing in a nullptr.- replaceWriteLogMessage- replaceWriteLogMessageExThis implementation is not compatible withC++ log handler objects.This implementation has minimal thread safety,in the sense that the function pointer are storedand read atomically. But otherwise, theuser-defined static functions must accept callsat all times, even after having been deregistered,because some log calls may have started beforederegistering.
@kinchungwongkinchungwongforce-pushed thelogging_callback_simple_c branch fromc788983 to59a3fe5CompareMarch 27, 2025 07:48
1. removes addressof (&) when taking address of a function.2. added function and typedef docs
@kinchungwongkinchungwong marked this pull request as ready for reviewMarch 30, 2025 09:08
Copy link
Contributor

@opencv-alalekopencv-alalek left a comment

Choose a reason for hiding this comment

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

Thank you for contribution!

LGTM 👍

@asmorkalovasmorkalov added this to the4.12.0 milestoneMar 30, 2025
@asmorkalovasmorkalov merged commitafc7c0a intoopencv:4.xMar 30, 2025
24 of 28 checks passed
@kinchungwongkinchungwong deleted the logging_callback_simple_c branchMarch 30, 2025 13:26
@patrikhuber
Copy link
Contributor

@kinchungwong Is there an example somewhere of how to use this functionality, like my wishful code in#27140 (comment)?

@mshabunin
Copy link
Contributor

@patrikhuber , I believe it works just like you've shown in the example, but the function is calledreplaceWriteLogMessageEx instead ofsetLogCallback. And callback function have slightly different arguments:(LogLevel logLevel, const char* tag, const char* file, int line, const char* func, const char* message).

kinchungwong and opencv-alalek reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@opencv-alalekopencv-alalekopencv-alalek approved these changes

Assignees

@opencv-alalekopencv-alalek

Projects

None yet

Milestone

4.12.0

Development

Successfully merging this pull request may close these issues.

5 participants

@kinchungwong@patrikhuber@mshabunin@opencv-alalek@asmorkalov

[8]ページ先頭

©2009-2025 Movatter.jp