Skip to content

Commit

Permalink
feat: add missing debug logging macros (#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
4c3y authored Dec 21, 2023
1 parent 6607b36 commit 716be9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ excessive logging.
DLOG(INFO) << "Found cookies";
DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
DLOG_FIRST_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
DLOG_EVERY_T(INFO, 0.01) << "Got a cookie";
``CHECK`` Macros
Expand Down
10 changes: 10 additions & 0 deletions src/glog/logging.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,8 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
#define DLOG_EVERY_N(severity, n) LOG_EVERY_N(severity, n)
#define DLOG_IF_EVERY_N(severity, condition, n) \
LOG_IF_EVERY_N(severity, condition, n)
#define DLOG_FIRST_N(severity, n) LOG_FIRST_N(severity, n)
#define DLOG_EVERY_T(severity, T) LOG_EVERY_T(severity, T)
#define DLOG_ASSERT(condition) LOG_ASSERT(condition)

// debug-only checking. executed if DCHECK_IS_ON().
Expand Down Expand Up @@ -1214,6 +1216,14 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
static_cast<void>(0), \
(true || !(condition))? (void) 0 : @ac_google_namespace@::LogMessageVoidify() & LOG(severity)

#define DLOG_FIRST_N(severity, n) \
static_cast<void>(0), \
true ? (void) 0 : @ac_google_namespace@::LogMessageVoidify() & LOG(severity)

#define DLOG_EVERY_T(severity, T) \
static_cast<void>(0), \
true ? (void) 0 : @ac_google_namespace@::LogMessageVoidify() & LOG(severity)

#define DLOG_ASSERT(condition) \
static_cast<void>(0), \
true ? (void) 0 : LOG_ASSERT(condition)
Expand Down

0 comments on commit 716be9e

Please sign in to comment.