Logging revamp for 4.1.0 (#11003, OE-11)#13642
Logging revamp for 4.1.0 (#11003, OE-11)#13642kinchungwong wants to merge 2 commits intoopencv:masterfrom kinchungwong:issue_11003_logging_revamp_cv410
Conversation
|
To prevent forced changes to all existing logging in application code, the new design must make sure existing log macros continue to work, even if their definitions are changed. The existing log macros refer to:
However, that means new features cannot be tested on these macros. To test the new features, currently one must use the new macro, Here are some examples of using Example 1 CV_LOGMETA(
NULL,
cv::utils::logging::LOG_LEVEL_DEBUG,
cv::utils::logging::LogModuleInfo("imgcodecs")
<< CV_LOG_LOC(),
"findDecoder(" << filename << ")"
);Example 2 CV_LOGMETA(
NULL,
cv::utils::logging::LOG_LEVEL_DEBUG,
cv::utils::logging::LogModuleInfo("imgcodecs")
<< CV_LOG_LOC()
<< CV_LOG_THIS(),
"Reading PNG header");In these examples,
|
|
This document provides some of the underlying thinking about why certain design decisions are made. https://gist.github.com/kinchungwong/6d24bd3d45424197a4d1495237cd9be3 |
Added class LogMeta and others. Added setLogFilter, getLogFilter. Added CV_LOGMETA. Added CV_LOG_LOC, CV_LOG_THIS. Modified CV_LOG_FATAL, CV_LOG_ERROR and others to use CV_LOGMETA. Added defaultLogFilter as a default implementation. Known issues: Building with CV_LOG_STRIP_LEVEL set to (CV_LOG_LEVEL_VERBOSE + 1) will cause compile errors due to syntax errors in the following files: - modules/core/src/ocl.cpp - modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp This is due to incorrect usage of the CV_LOG_VERBOSE macro, or trying to access non-existent C++ class members. This commit does not fix these known issues; a separate PR will be submitted independently of Issue 11003.
Spec: #11003 (comment) Summary: added class LogScope; added enum class LogConfigLayer; added class LogThreshold; added class LogManager; added hash helper functions in namespace cv::utils::logging::hash_utility; Details: A prototype that demonstrates configuring log level filtering threshold at runtime using a hierarchy (nesting) of LogScope. Typically LogScope are instantiated as static variables at namespace, class, or function local scope level. A nested LogScope is declared by providing a ref to the outer LogScope when calling the constructor. Each LogScope has a name. A LogScope has a fully-qualified name formed from concatenating the names of its parents with its own, joined by the period char (decimal 46, hex 2E). A FNV-1a 64-bit hash is computed from this fully-qualified name, and used as the lookup key in LogManager. (LogManager assumes there is no collision for this 64-bit hash value; string comparison is not performed due to speed reasons.) Log filtering thresholds for any scope can be changed at any time. Requires C++11: unordered_map, atomic, memory Remarks: The source code is now in a hybrid state. The older LogMeta class is still in the commit; LogModuleInfo is replaced by LogScope. However, the macros have not been updated yet.
|
@alalek I probably need help writing a preprocessor check for GCC versions and C++ language versions (inside preprocessor code) in which |
|
This PR is too far off from current design, not possible to contribute (merge) and/or improve. Closing PR. |
does_not_resolve_yet #11003
This pullrequest changes
Added class LogMeta and others.
Added setLogFilter, getLogFilter.
Added CV_LOGMETA.
Added CV_LOG_LOC, CV_LOG_THIS.
Modified CV_LOG_FATAL, CV_LOG_ERROR and others to use CV_LOGMETA.
Added defaultLogFilter as a default implementation.
Known issues
Building with CV_LOG_STRIP_LEVEL set to (CV_LOG_LEVEL_VERBOSE + 1) will cause compile errors due to syntax errors in the following files:
This is due to incorrect usage of the CV_LOG_VERBOSE macro, or trying to access non-existent C++ class members.
This commit does not fix these known issues; a separate PR will be submitted independently of Issue 11003.
Progress
Checklist for core module changes
to accept LogMeta (or its data members) so that backends that can benefit from those
data can use them programmatically without parsing from strings.
Checklist for required changes in every OpenCV module
Checklist for long-term improvement changes in every OpenCV module