5 #ifndef OPENCV_LOGGER_HPP
6 #define OPENCV_LOGGER_HPP
12 #include "logger.defines.hpp"
63 #ifndef CV_LOG_STRIP_LEVEL
65 # define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG
67 # define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE
71 #define CV_LOGTAG_PTR_CAST(expr) static_cast<const cv::utils::logging::LogTag*>(expr)
93 #define CV_LOGTAG_EXPAND_NAME(tag) tag
99 #define CV_LOGTAG_FALLBACK nullptr
105 #define CV_LOGTAG_GLOBAL cv::utils::logging::internal::getGlobalLogTag()
107 #define CV_LOG_WITH_TAG(tag, msgLevel, extra_check0, extra_check1, ...) \
110 const auto cv_temp_msglevel = (cv::utils::logging::LogLevel)(msgLevel); \
111 if (cv_temp_msglevel >= (CV_LOG_STRIP_LEVEL)) break; \
112 auto cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_EXPAND_NAME(tag)); \
113 if (!cv_temp_logtagptr) cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_FALLBACK); \
114 if (!cv_temp_logtagptr) cv_temp_logtagptr = CV_LOGTAG_PTR_CAST(CV_LOGTAG_GLOBAL); \
115 if (cv_temp_logtagptr && (cv_temp_msglevel > cv_temp_logtagptr->level)) break; \
117 std::stringstream cv_temp_logstream; \
118 cv_temp_logstream << __VA_ARGS__; \
119 cv::utils::logging::internal::writeLogMessageEx( \
121 (cv_temp_logtagptr ? cv_temp_logtagptr->name : nullptr), \
125 cv_temp_logstream.str().c_str()); \
129 #define CV_LOG_FATAL(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_FATAL, , , __VA_ARGS__)
130 #define CV_LOG_ERROR(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, , , __VA_ARGS__)
131 #define CV_LOG_WARNING(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, , , __VA_ARGS__)
132 #define CV_LOG_INFO(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, , , __VA_ARGS__)
133 #define CV_LOG_DEBUG(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, , , __VA_ARGS__)
134 #define CV_LOG_VERBOSE(tag, v, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), , , __VA_ARGS__)
136 #if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO
138 #define CV_LOG_INFO(tag, ...)
141 #if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG
143 #define CV_LOG_DEBUG(tag, ...)
146 #if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE
147 #undef CV_LOG_VERBOSE
148 #define CV_LOG_VERBOSE(tag, v, ...)
152 #define CV__LOG_ONCE_CHECK_PRE \
153 static bool _cv_log_once_ ## __LINE__ = false; \
154 if (_cv_log_once_ ## __LINE__) break;
156 #define CV__LOG_ONCE_CHECK_POST \
157 _cv_log_once_ ## __LINE__ = true;
159 #define CV__LOG_IF_CHECK(logging_cond) \
160 if (!(logging_cond)) break;
167 #define CV_LOG_ONCE_ERROR(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
168 #define CV_LOG_ONCE_WARNING(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
169 #define CV_LOG_ONCE_INFO(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
170 #define CV_LOG_ONCE_DEBUG(tag, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
171 #define CV_LOG_ONCE_VERBOSE(tag, v, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), CV__LOG_ONCE_CHECK_PRE, CV__LOG_ONCE_CHECK_POST, __VA_ARGS__)
173 #if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO
174 #undef CV_LOG_ONCE_INFO
175 #define CV_LOG_ONCE_INFO(tag, ...)
178 #if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG
179 #undef CV_LOG_ONCE_DEBUG
180 #define CV_LOG_ONCE_DEBUG(tag, ...)
183 #if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE
184 #undef CV_LOG_ONCE_VERBOSE
185 #define CV_LOG_ONCE_VERBOSE(tag, v, ...)
191 #define CV_LOG_IF_FATAL(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_FATAL, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
192 #define CV_LOG_IF_ERROR(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_ERROR, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
193 #define CV_LOG_IF_WARNING(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_WARNING, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
194 #define CV_LOG_IF_INFO(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_INFO, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
195 #define CV_LOG_IF_DEBUG(tag, logging_cond, ...) CV_LOG_WITH_TAG(tag, cv::utils::logging::LOG_LEVEL_DEBUG, , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
196 #define CV_LOG_IF_VERBOSE(tag, v, logging_cond, ...) CV_LOG_WITH_TAG(tag, (cv::utils::logging::LOG_LEVEL_VERBOSE + (int)(v)), , CV__LOG_IF_CHECK(logging_cond), __VA_ARGS__)
198 #if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO
199 #undef CV_LOG_IF_INFO
200 #define CV_LOG_IF_INFO(tag, logging_cond, ...)
203 #if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG
204 #undef CV_LOG_IF_DEBUG
205 #define CV_LOG_IF_DEBUG(tag, logging_cond, ...)
208 #if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE
209 #undef CV_LOG_IF_VERBOSE
210 #define CV_LOG_IF_VERBOSE(tag, v, logging_cond, ...)
CvCmpFunc func
Definition: core_c.h:1712
CV_EXPORTS LogLevel getLogLevel()
CV_EXPORTS void registerLogTag(cv::utils::logging::LogTag *plogtag)
CV_EXPORTS void setLogTagLevel(const char *tag, cv::utils::logging::LogLevel level)
CV_EXPORTS cv::utils::logging::LogLevel getLogTagLevel(const char *tag)
CV_EXPORTS LogLevel setLogLevel(LogLevel logLevel)
#define CV_EXPORTS
Definition: cvdef.h:435
CV_EXPORTS_W void line(InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a line segment connecting two points.
CV_EXPORTS cv::utils::logging::LogTag * getGlobalLogTag()
CV_EXPORTS void writeLogMessage(LogLevel logLevel, const char *message)
CV_EXPORTS void writeLogMessageEx(LogLevel logLevel, const char *tag, const char *file, int line, const char *func, const char *message)
LogLevel
Supported logging levels and their semantic.
Definition: logger.defines.hpp:25
"black box" representation of the file storage associated with a file on disk.
Definition: calib3d.hpp:441
Definition: logger.hpp:50
LogTagAuto(const char *_name, LogLevel _level)
Definition: logger.hpp:51
Definition: logtag.hpp:16