Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit 18bbf15

Browse files
committed
added LOG_TO_SINK_IF and DLOG_TO_SINK
1 parent 570c7e4 commit 18bbf15

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/glog/logging.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,12 @@ class LogSink; // defined below
540540
? (void)0 \
541541
: google::logging::internal::LogMessageVoidify() & SYSLOG(severity)
542542

543+
#define LOG_TO_SINK_IF(sink, severity, condition) \
544+
static_cast<void>(0), \
545+
!(condition) \
546+
? (void)0 \
547+
: google::logging::internal::LogMessageVoidify() & LOG_TO_SINK(sink, severity)
548+
543549
#define LOG_ASSERT(condition) \
544550
LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
545551
#define SYSLOG_ASSERT(condition) \
@@ -1019,6 +1025,7 @@ constexpr LogSeverity GLOG_0 = GLOG_ERROR;
10191025
# define DLOG_FIRST_N(severity, n) LOG_FIRST_N(severity, n)
10201026
# define DLOG_EVERY_T(severity, T) LOG_EVERY_T(severity, T)
10211027
# define DLOG_ASSERT(condition) LOG_ASSERT(condition)
1028+
# define DLOG_TO_SINK(sink, severity) LOG_TO_SINK(sink, severity)
10221029

10231030
// debug-only checking. executed if DCHECK_IS_ON().
10241031
# define DCHECK(condition) CHECK(condition)
@@ -1077,6 +1084,11 @@ constexpr LogSeverity GLOG_0 = GLOG_ERROR;
10771084
# define DLOG_ASSERT(condition) \
10781085
static_cast<void>(0), true ? (void)0 : (LOG_ASSERT(condition))
10791086

1087+
# define DLOG_TO_SINK(sink, severity) \
1088+
static_cast<void>(0), \
1089+
true ? (void)0 \
1090+
: google::logging::internal::LogMessageVoidify() & LOG(severity)
1091+
10801092
// MSVC warning C4127: conditional expression is constant
10811093
# define DCHECK(condition) \
10821094
GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \

0 commit comments

Comments
 (0)