57 #define XLOG(level, ...) \ 59 ::folly::LogLevel::level, \ 60 ::folly::LogStreamProcessor::APPEND, \ 68 #define XLOG_IF(level, cond, ...) \ 70 ::folly::LogLevel::level, \ 72 ::folly::LogStreamProcessor::APPEND, \ 77 #define XLOGF(level, fmt, arg1, ...) \ 79 ::folly::LogLevel::level, \ 80 ::folly::LogStreamProcessor::FORMAT, \ 90 #define XLOGF_IF(level, cond, fmt, arg1, ...) \ 92 ::folly::LogLevel::level, \ 94 ::folly::LogStreamProcessor::FORMAT, \ 105 #define XLOG_EVERY_MS(level, ms, ...) \ 109 static ::folly::logging::IntervalRateLimiter \ 110 folly_detail_xlog_limiter(1, std::chrono::milliseconds(ms)); \ 111 return folly_detail_xlog_limiter.check(); \ 121 #define XLOG_EVERY_N(level, n, ...) \ 125 static std::atomic<size_t> folly_detail_xlog_count{0}; \ 126 return FOLLY_UNLIKELY( \ 127 (folly_detail_xlog_count.fetch_add(1, std::memory_order_relaxed) % \ 138 #define XLOG_N_PER_MS(level, count, ms, ...) \ 142 static ::folly::logging::IntervalRateLimiter \ 143 folly_detail_xlog_limiter((count), std::chrono::milliseconds(ms)); \ 144 return folly_detail_xlog_limiter.check(); \ 158 #ifdef FOLLY_XLOG_STRIP_PREFIXES 159 #define XLOG_FILENAME \ 160 folly::xlogStripFilename(__FILE__, FOLLY_XLOG_STRIP_PREFIXES) 162 #define XLOG_FILENAME __FILE__ 165 #define XLOG_IMPL(level, type, ...) \ 167 level, true, ::folly::isLogLevelFatal(level), type, ##__VA_ARGS__) 169 #define XLOG_IF_IMPL(level, cond, type, ...) \ 170 XLOG_ACTUAL_IMPL(level, cond, false, type, ##__VA_ARGS__) 215 #define XLOG_ACTUAL_IMPL(level, cond, always_fatal, type, ...) \ 216 (!XLOG_IS_ON_IMPL(level) || !(cond)) \ 217 ? ::folly::logDisabledHelper(::folly::bool_constant<always_fatal>{}) \ 218 : ::folly::LogStreamVoidify<::folly::isLogLevelFatal(level)>{} & \ 219 ::folly::LogStreamProcessor( \ 221 static ::folly::XlogCategoryInfo<XLOG_IS_IN_HEADER_FILE> \ 222 folly_detail_xlog_category; \ 223 return folly_detail_xlog_category.getInfo( \ 224 &xlog_detail::xlogFileScopeInfo); \ 227 xlog_detail::getXlogCategoryName(XLOG_FILENAME, 0), \ 228 xlog_detail::isXlogCategoryOverridden(0), \ 241 #define XLOG_IS_ON(level) XLOG_IS_ON_IMPL(::folly::LogLevel::level) 258 #define XLOG_IS_ON_IMPL(level) \ 260 static ::folly::XlogLevelInfo<XLOG_IS_IN_HEADER_FILE> \ 261 folly_detail_xlog_level; \ 262 return folly_detail_xlog_level.check( \ 264 xlog_detail::getXlogCategoryName(XLOG_FILENAME, 0), \ 265 xlog_detail::isXlogCategoryOverridden(0), \ 266 &xlog_detail::xlogFileScopeInfo); \ 273 #define XLOG_GET_CATEGORY_NAME() \ 274 (xlog_detail::isXlogCategoryOverridden(0) \ 275 ? xlog_detail::getXlogCategoryName(XLOG_FILENAME, 0) \ 276 : ::folly::getXlogCategoryNameForFile(XLOG_FILENAME)) 286 #define XLOG_GET_CATEGORY() \ 287 folly::LoggerDB::get().getCategory(XLOG_GET_CATEGORY_NAME()) 301 #ifdef __INCLUDE_LEVEL__ 302 #define XLOG_SET_CATEGORY_CHECK \ 304 __INCLUDE_LEVEL__ == 0, \ 305 "XLOG_SET_CATEGORY_NAME() should not be used in header files"); 307 #define XLOG_SET_CATEGORY_CHECK 310 #define XLOG_SET_CATEGORY_NAME(category) \ 312 namespace xlog_detail { \ 313 XLOG_SET_CATEGORY_CHECK \ 314 constexpr inline folly::StringPiece getXlogCategoryName( \ 315 folly::StringPiece, \ 319 constexpr inline bool isXlogCategoryOverridden(int) { \ 332 #define XCHECK(cond, ...) \ 333 XLOG_IF(FATAL, UNLIKELY(!(cond)), "Check failed: " #cond " ", ##__VA_ARGS__) 346 #define XDCHECK(cond, ...) \ 347 (!::folly::kIsDebug) ? static_cast<void>(0) : XCHECK(cond, ##__VA_ARGS__) 353 #ifdef __INCLUDE_LEVEL__ 354 #define XLOG_IS_IN_HEADER_FILE bool(__INCLUDE_LEVEL__ > 0) 358 #define XLOG_IS_IN_HEADER_FILE true 365 #ifdef __INCLUDE_LEVEL__ 366 std::atomic<::folly::LogLevel> level;
380 template <
bool IsInHeaderFile>
394 if (
LIKELY(levelToCheck < level_.load(std::memory_order_relaxed))) {
406 auto currentLevel = loadLevelFull(categoryName, isOverridden);
407 return levelToCheck >= currentLevel;
418 template <
bool IsInHeaderFile>
422 return isInitialized_.load(std::memory_order_acquire);
445 #ifdef __INCLUDE_LEVEL__ 463 fileScopeInfo->level.load(::std::memory_order_relaxed))) {
470 loadLevelFull(categoryName, isOverridden, fileScopeInfo);
471 return levelToCheck >= currentLevel;
495 return fileScopeInfo;
514 const char* filename,
515 const char* prefixes,
520 const char* filename,
521 const char* prefixes,
523 size_t filenameIdx) {
524 return (filename[filenameIdx] ==
'\0')
528 filename, prefixes, prefixIdx, filenameIdx + 1)
529 : (filename + filenameIdx));
532 const char* filename,
533 const char* prefixes,
541 return (prefixes[prefixIdx] ==
':' || prefixes[prefixIdx] ==
'\0')
542 ? ((match && filenameIdx > 0 &&
546 filename, prefixes, prefixIdx, filenameIdx))
547 : ((prefixes[prefixIdx] ==
'\0')
550 filename, prefixes, prefixIdx + 1, 0,
true)))
551 : ((match && (prefixes[prefixIdx] == filename[filenameIdx]))
553 filename, prefixes, prefixIdx + 1, filenameIdx + 1,
true)
555 filename, prefixes, prefixIdx + 1, 0,
false));
576 const char* filename,
577 const char* prefixes) {
607 template <
typename T>
625 template <
typename T>
626 constexpr
inline bool isXlogCategoryOverridden(
T) {
constexpr bool xlogIsDirSeparator(char c)
—— Concurrent Priority Queue Implementation ——
LogCategory * getCategory(XlogFileScopeInfo *)
StringPiece getXlogCategoryNameForFile(StringPiece filename)
void init(int *argc, char ***argv, bool removeFlags)
constexpr const char * xlogStripFilename(const char *filename, const char *prefixes)
std::atomic< LogLevel > level_
std::atomic< bool > isInitialized_
bool check(LogLevel levelToCheck, folly::StringPiece categoryName, bool isOverridden, XlogFileScopeInfo *)
XlogCategoryInfo< IsInHeaderFile > * getInfo(XlogFileScopeInfo *)
constexpr const char * xlogStripFilenameRecursive(const char *filename, const char *prefixes, size_t prefixIdx, size_t filenameIdx, bool match)
bool isInitialized() const
constexpr const char * xlogStripFilenameMatchFound(const char *filename, const char *prefixes, size_t prefixIdx, size_t filenameIdx)
constexpr auto kIsWindows
bool check(const dynamic &schema, const dynamic &value, bool check=true)