// // Logging macros // // Usage: // log_<level>(<comma separated log tags>)(<printf-style log arguments>); // e.g. // log_debug(logging)("message %d", i); // // Note that these macros will not evaluate the arguments unless the logging is enabled. // #define log_error(...) (!log_is_enabled(Error, __VA_ARGS__)) ? (void)0 : LogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Error> #define log_warning(...) (!log_is_enabled(Warning, __VA_ARGS__)) ? (void)0 : LogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Warning> #define log_info(...) (!log_is_enabled(Info, __VA_ARGS__)) ? (void)0 : LogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Info> #define log_debug(...) (!log_is_enabled(Debug, __VA_ARGS__)) ? (void)0 : LogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Debug> #define log_trace(...) (!log_is_enabled(Trace, __VA_ARGS__)) ? (void)0 : LogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Trace>
// Macros for logging that should be excluded in product builds. // Available for levels Info, Debug and Trace. Includes test macro that // evaluates to false in product builds. #ifndef PRODUCT #define log_develop_info(...) (!log_is_enabled(Info, __VA_ARGS__)) ? (void)0 : LogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Info> #define log_develop_debug(...) (!log_is_enabled(Debug, __VA_ARGS__)) ? (void)0 : LogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Debug> #define log_develop_trace(...) (!log_is_enabled(Trace, __VA_ARGS__)) ? (void)0 : LogImpl<LOG_TAGS(__VA_ARGS__)>::write<LogLevel::Trace> #define log_develop_is_enabled(level, ...) log_is_enabled(level, __VA_ARGS__) #else #define DUMMY_ARGUMENT_CONSUMER(...) #define log_develop_info(...) DUMMY_ARGUMENT_CONSUMER #define log_develop_debug(...) DUMMY_ARGUMENT_CONSUMER #define log_develop_trace(...) DUMMY_ARGUMENT_CONSUMER #define log_develop_is_enabled(...) false #endif
// Convenience macro to test if the logging is enabled on the specified level for given tags. #define log_is_enabled(level, ...) (LogImpl<LOG_TAGS(__VA_ARGS__)>::is_level(LogLevel::level))
// // Log class for more advanced logging scenarios. // Has printf-style member functions for each log level (trace(), debug(), etc). // // The (trace(), debug(), etc) functions can also be used along with the LogStream // class to obtain an outputStream object, to be passed to various printing // functions that accept an outputStream: // // Example usage: // Log(codecache, sweep) log; // if (log.is_debug()) { // log.debug("result = %d", result).trace(" tracing info"); // LogStream ls(log.debug()); // CodeCache::print_summary(&ls, false); // } // #define Log(...) LogImpl<LOG_TAGS(__VA_ARGS__)>
// // Log class that embeds both log tags and a log level. // // The class provides a way to write the tags and log level once, // so that redundant specification of tags or levels can be avoided. // // Example usage: // LogTarget(Debug, codecache, sweep) out; // if (out.is_enabled()) { // out.print("result = %d", result); // LogStream ls(out); // CodeCache::print_summary(&ls, false); // } // #define LogTarget(level, ...) LogTargetImpl<LogLevel::level, LOG_TAGS(__VA_ARGS__)>
template <LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG, LogTagType T3 = LogTag::__NO_TAG,
LogTagType T4 = LogTag::__NO_TAG, LogTagType GuardTag = LogTag::__NO_TAG> class LogImpl { public: // Make sure no more than the maximum number of tags have been given. // The GuardTag allows this to be detected if/when it happens. If the GuardTag // is not __NO_TAG, the number of tags given exceeds the maximum allowed.
STATIC_ASSERT(GuardTag == LogTag::__NO_TAG); // Number of logging tags exceeds maximum supported!
// Empty constructor to avoid warnings on MSVC about unused variables // when the log instance is only used for static functions.
LogImpl() {
}
// Combines logging tags and a logging level. template <LogLevelType level, LogTagType T0, LogTagType T1 = LogTag::__NO_TAG, LogTagType T2 = LogTag::__NO_TAG,
LogTagType T3 = LogTag::__NO_TAG, LogTagType T4 = LogTag::__NO_TAG, LogTagType GuardTag = LogTag::__NO_TAG> class LogTargetImpl { public: // Empty constructor to avoid warnings on MSVC about unused variables // when the log instance is only used for static functions.
LogTargetImpl() {
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.