Define GLOG_ prefixed log severities
Users can control if usual log severity values will be defined by GLOG_NO_ABBREVIATED_SEVERITIES. For http://code.google.com/p/google-glog/issues/detail?id=105 git-svn-id: https://google-glog.googlecode.com/svn/trunk@101 eb4d4688-79bd-11dd-afb4-1d65580434c0
This commit is contained in:
parent
8a4c1663e3
commit
6febec361e
@ -527,8 +527,48 @@ all log messages associated with <code>VLOG</code>s as well as
|
|||||||
<h3><A NAME=windows>Notes for Windows users</A></h3>
|
<h3><A NAME=windows>Notes for Windows users</A></h3>
|
||||||
|
|
||||||
<p>Google glog defines a severity level <code>ERROR</code>, which is
|
<p>Google glog defines a severity level <code>ERROR</code>, which is
|
||||||
also defined in <code>windows.h</code>
|
also defined in <code>windows.h</code> . You can make glog not define
|
||||||
There are two known workarounds to avoid this conflict:
|
<code>INFO</code>, <code>WARNING</code>, <code>ERROR</code>,
|
||||||
|
and <code>FATAL</code> by defining
|
||||||
|
<code>GLOG_NO_ABBREVIATED_SEVERITIES</code> before
|
||||||
|
including <code>glog/logging.h</code> . Even with this macro, you can
|
||||||
|
still use the iostream like logging facilities:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
#define GLOG_NO_ABBREVIATED_SEVERITIES
|
||||||
|
#include <windows.h>
|
||||||
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
LOG(ERROR) << "This should work";
|
||||||
|
LOG_IF(ERROR, x > y) << "This should be also OK";
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
However, you cannot
|
||||||
|
use <code>INFO</code>, <code>WARNING</code>, <code>ERROR</code>,
|
||||||
|
and <code>FATAL</code> anymore for functions defined
|
||||||
|
in <code>glog/logging.h</code> .
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
#define GLOG_NO_ABBREVIATED_SEVERITIES
|
||||||
|
#include <windows.h>
|
||||||
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
// This won't work.
|
||||||
|
// google::FlushLogFiles(google::ERROR);
|
||||||
|
|
||||||
|
// Use this instead.
|
||||||
|
google::FlushLogFiles(google::GLOG_ERROR);
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you don't need <code>ERROR</code> defined
|
||||||
|
by <code>windows.h</code>, there are a couple of more workarounds
|
||||||
|
which sometimes don't work:
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>#define <code>WIN32_LEAN_AND_MEAN</code> or <code>NOGDI</code>
|
<li>#define <code>WIN32_LEAN_AND_MEAN</code> or <code>NOGDI</code>
|
||||||
|
|||||||
@ -44,7 +44,15 @@
|
|||||||
// you ever need to change their values or add a new severity.
|
// you ever need to change their values or add a new severity.
|
||||||
typedef int LogSeverity;
|
typedef int LogSeverity;
|
||||||
|
|
||||||
const int INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3, NUM_SEVERITIES = 4;
|
const int GLOG_INFO = 0, GLOG_WARNING = 1, GLOG_ERROR = 2, GLOG_FATAL = 3,
|
||||||
|
NUM_SEVERITIES = 4;
|
||||||
|
#ifndef GLOG_NO_ABBREVIATED_SEVERITIES
|
||||||
|
# ifdef ERROR
|
||||||
|
# error ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail.
|
||||||
|
# endif
|
||||||
|
const int INFO = GLOG_INFO, WARNING = GLOG_WARNING,
|
||||||
|
ERROR = GLOG_ERROR, FATAL = GLOG_FATAL;
|
||||||
|
#endif
|
||||||
|
|
||||||
// DFATAL is FATAL in debug mode, ERROR in normal mode
|
// DFATAL is FATAL in debug mode, ERROR in normal mode
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
|
|||||||
@ -368,7 +368,7 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
#define COMPACT_GOOGLE_LOG_INFO @ac_google_namespace@::LogMessage( \
|
#define COMPACT_GOOGLE_LOG_INFO @ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__)
|
__FILE__, __LINE__)
|
||||||
#define LOG_TO_STRING_INFO(message) @ac_google_namespace@::LogMessage( \
|
#define LOG_TO_STRING_INFO(message) @ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::INFO, message)
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_INFO, message)
|
||||||
#else
|
#else
|
||||||
#define COMPACT_GOOGLE_LOG_INFO @ac_google_namespace@::NullStream()
|
#define COMPACT_GOOGLE_LOG_INFO @ac_google_namespace@::NullStream()
|
||||||
#define LOG_TO_STRING_INFO(message) @ac_google_namespace@::NullStream()
|
#define LOG_TO_STRING_INFO(message) @ac_google_namespace@::NullStream()
|
||||||
@ -376,9 +376,9 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
|
|
||||||
#if GOOGLE_STRIP_LOG <= 1
|
#if GOOGLE_STRIP_LOG <= 1
|
||||||
#define COMPACT_GOOGLE_LOG_WARNING @ac_google_namespace@::LogMessage( \
|
#define COMPACT_GOOGLE_LOG_WARNING @ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::WARNING)
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_WARNING)
|
||||||
#define LOG_TO_STRING_WARNING(message) @ac_google_namespace@::LogMessage( \
|
#define LOG_TO_STRING_WARNING(message) @ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::WARNING, message)
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_WARNING, message)
|
||||||
#else
|
#else
|
||||||
#define COMPACT_GOOGLE_LOG_WARNING @ac_google_namespace@::NullStream()
|
#define COMPACT_GOOGLE_LOG_WARNING @ac_google_namespace@::NullStream()
|
||||||
#define LOG_TO_STRING_WARNING(message) @ac_google_namespace@::NullStream()
|
#define LOG_TO_STRING_WARNING(message) @ac_google_namespace@::NullStream()
|
||||||
@ -386,9 +386,9 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
|
|
||||||
#if GOOGLE_STRIP_LOG <= 2
|
#if GOOGLE_STRIP_LOG <= 2
|
||||||
#define COMPACT_GOOGLE_LOG_ERROR @ac_google_namespace@::LogMessage( \
|
#define COMPACT_GOOGLE_LOG_ERROR @ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::ERROR)
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR)
|
||||||
#define LOG_TO_STRING_ERROR(message) @ac_google_namespace@::LogMessage( \
|
#define LOG_TO_STRING_ERROR(message) @ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::ERROR, message)
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR, message)
|
||||||
#else
|
#else
|
||||||
#define COMPACT_GOOGLE_LOG_ERROR @ac_google_namespace@::NullStream()
|
#define COMPACT_GOOGLE_LOG_ERROR @ac_google_namespace@::NullStream()
|
||||||
#define LOG_TO_STRING_ERROR(message) @ac_google_namespace@::NullStream()
|
#define LOG_TO_STRING_ERROR(message) @ac_google_namespace@::NullStream()
|
||||||
@ -398,7 +398,7 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
#define COMPACT_GOOGLE_LOG_FATAL @ac_google_namespace@::LogMessageFatal( \
|
#define COMPACT_GOOGLE_LOG_FATAL @ac_google_namespace@::LogMessageFatal( \
|
||||||
__FILE__, __LINE__)
|
__FILE__, __LINE__)
|
||||||
#define LOG_TO_STRING_FATAL(message) @ac_google_namespace@::LogMessage( \
|
#define LOG_TO_STRING_FATAL(message) @ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::FATAL, message)
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_FATAL, message)
|
||||||
#else
|
#else
|
||||||
#define COMPACT_GOOGLE_LOG_FATAL @ac_google_namespace@::NullStreamFatal()
|
#define COMPACT_GOOGLE_LOG_FATAL @ac_google_namespace@::NullStreamFatal()
|
||||||
#define LOG_TO_STRING_FATAL(message) @ac_google_namespace@::NullStreamFatal()
|
#define LOG_TO_STRING_FATAL(message) @ac_google_namespace@::NullStreamFatal()
|
||||||
@ -410,32 +410,32 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
|
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
|
||||||
#elif GOOGLE_STRIP_LOG <= 3
|
#elif GOOGLE_STRIP_LOG <= 3
|
||||||
#define COMPACT_GOOGLE_LOG_DFATAL @ac_google_namespace@::LogMessage( \
|
#define COMPACT_GOOGLE_LOG_DFATAL @ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::FATAL)
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_FATAL)
|
||||||
#else
|
#else
|
||||||
#define COMPACT_GOOGLE_LOG_DFATAL @ac_google_namespace@::NullStreamFatal()
|
#define COMPACT_GOOGLE_LOG_DFATAL @ac_google_namespace@::NullStreamFatal()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GOOGLE_LOG_INFO(counter) @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::INFO, counter, &@ac_google_namespace@::LogMessage::SendToLog)
|
#define GOOGLE_LOG_INFO(counter) @ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_INFO, counter, &@ac_google_namespace@::LogMessage::SendToLog)
|
||||||
#define SYSLOG_INFO(counter) \
|
#define SYSLOG_INFO(counter) \
|
||||||
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::INFO, counter, \
|
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_INFO, counter, \
|
||||||
&@ac_google_namespace@::LogMessage::SendToSyslogAndLog)
|
&@ac_google_namespace@::LogMessage::SendToSyslogAndLog)
|
||||||
#define GOOGLE_LOG_WARNING(counter) \
|
#define GOOGLE_LOG_WARNING(counter) \
|
||||||
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::WARNING, counter, \
|
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_WARNING, counter, \
|
||||||
&@ac_google_namespace@::LogMessage::SendToLog)
|
&@ac_google_namespace@::LogMessage::SendToLog)
|
||||||
#define SYSLOG_WARNING(counter) \
|
#define SYSLOG_WARNING(counter) \
|
||||||
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::WARNING, counter, \
|
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_WARNING, counter, \
|
||||||
&@ac_google_namespace@::LogMessage::SendToSyslogAndLog)
|
&@ac_google_namespace@::LogMessage::SendToSyslogAndLog)
|
||||||
#define GOOGLE_LOG_ERROR(counter) \
|
#define GOOGLE_LOG_ERROR(counter) \
|
||||||
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::ERROR, counter, \
|
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR, counter, \
|
||||||
&@ac_google_namespace@::LogMessage::SendToLog)
|
&@ac_google_namespace@::LogMessage::SendToLog)
|
||||||
#define SYSLOG_ERROR(counter) \
|
#define SYSLOG_ERROR(counter) \
|
||||||
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::ERROR, counter, \
|
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR, counter, \
|
||||||
&@ac_google_namespace@::LogMessage::SendToSyslogAndLog)
|
&@ac_google_namespace@::LogMessage::SendToSyslogAndLog)
|
||||||
#define GOOGLE_LOG_FATAL(counter) \
|
#define GOOGLE_LOG_FATAL(counter) \
|
||||||
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::FATAL, counter, \
|
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_FATAL, counter, \
|
||||||
&@ac_google_namespace@::LogMessage::SendToLog)
|
&@ac_google_namespace@::LogMessage::SendToLog)
|
||||||
#define SYSLOG_FATAL(counter) \
|
#define SYSLOG_FATAL(counter) \
|
||||||
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::FATAL, counter, \
|
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_FATAL, counter, \
|
||||||
&@ac_google_namespace@::LogMessage::SendToSyslogAndLog)
|
&@ac_google_namespace@::LogMessage::SendToSyslogAndLog)
|
||||||
#define GOOGLE_LOG_DFATAL(counter) \
|
#define GOOGLE_LOG_DFATAL(counter) \
|
||||||
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::DFATAL_LEVEL, counter, \
|
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::DFATAL_LEVEL, counter, \
|
||||||
@ -454,7 +454,7 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
FORMAT_MESSAGE_FROM_SYSTEM, \
|
FORMAT_MESSAGE_FROM_SYSTEM, \
|
||||||
0, result, 0, msg, 100, NULL); \
|
0, result, 0, msg, 100, NULL); \
|
||||||
if (message_length > 0) { \
|
if (message_length > 0) { \
|
||||||
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, ERROR, 0, \
|
@ac_google_namespace@::LogMessage(__FILE__, __LINE__, @ac_google_namespace@::GLOG_ERROR, 0, \
|
||||||
&@ac_google_namespace@::LogMessage::SendToLog).stream() << message; \
|
&@ac_google_namespace@::LogMessage::SendToLog).stream() << message; \
|
||||||
LocalFree(message); \
|
LocalFree(message); \
|
||||||
} \
|
} \
|
||||||
@ -501,12 +501,12 @@ class LogSink; // defined below
|
|||||||
#define LOG_TO_SINK(sink, severity) \
|
#define LOG_TO_SINK(sink, severity) \
|
||||||
@ac_google_namespace@::LogMessage( \
|
@ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, \
|
__FILE__, __LINE__, \
|
||||||
@ac_google_namespace@::severity, \
|
@ac_google_namespace@::GLOG_ ## severity, \
|
||||||
static_cast<@ac_google_namespace@::LogSink*>(sink), true).stream()
|
static_cast<@ac_google_namespace@::LogSink*>(sink), true).stream()
|
||||||
#define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity) \
|
#define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity) \
|
||||||
@ac_google_namespace@::LogMessage( \
|
@ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, \
|
__FILE__, __LINE__, \
|
||||||
@ac_google_namespace@::severity, \
|
@ac_google_namespace@::GLOG_ ## severity, \
|
||||||
static_cast<@ac_google_namespace@::LogSink*>(sink), false).stream()
|
static_cast<@ac_google_namespace@::LogSink*>(sink), false).stream()
|
||||||
|
|
||||||
// If a non-NULL string pointer is given, we write this message to that string.
|
// If a non-NULL string pointer is given, we write this message to that string.
|
||||||
@ -771,7 +771,7 @@ DECLARE_CHECK_STROP_IMPL(strcasecmp, false)
|
|||||||
|
|
||||||
#define GOOGLE_PLOG(severity, counter) \
|
#define GOOGLE_PLOG(severity, counter) \
|
||||||
@ac_google_namespace@::ErrnoLogMessage( \
|
@ac_google_namespace@::ErrnoLogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::severity, counter, \
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, counter, \
|
||||||
&@ac_google_namespace@::LogMessage::SendToLog)
|
&@ac_google_namespace@::LogMessage::SendToLog)
|
||||||
|
|
||||||
#define PLOG_IF(severity, condition) \
|
#define PLOG_IF(severity, condition) \
|
||||||
@ -810,7 +810,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
|
|||||||
if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
|
if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
|
||||||
if (LOG_OCCURRENCES_MOD_N == 1) \
|
if (LOG_OCCURRENCES_MOD_N == 1) \
|
||||||
@ac_google_namespace@::LogMessage( \
|
@ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::severity, LOG_OCCURRENCES, \
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, LOG_OCCURRENCES, \
|
||||||
&what_to_do).stream()
|
&what_to_do).stream()
|
||||||
|
|
||||||
#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
|
#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
|
||||||
@ -819,7 +819,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
|
|||||||
if (condition && \
|
if (condition && \
|
||||||
((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \
|
((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \
|
||||||
@ac_google_namespace@::LogMessage( \
|
@ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::severity, LOG_OCCURRENCES, \
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, LOG_OCCURRENCES, \
|
||||||
&what_to_do).stream()
|
&what_to_do).stream()
|
||||||
|
|
||||||
#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
|
#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
|
||||||
@ -828,7 +828,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
|
|||||||
if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
|
if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
|
||||||
if (LOG_OCCURRENCES_MOD_N == 1) \
|
if (LOG_OCCURRENCES_MOD_N == 1) \
|
||||||
@ac_google_namespace@::ErrnoLogMessage( \
|
@ac_google_namespace@::ErrnoLogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::severity, LOG_OCCURRENCES, \
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, LOG_OCCURRENCES, \
|
||||||
&what_to_do).stream()
|
&what_to_do).stream()
|
||||||
|
|
||||||
#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
|
#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
|
||||||
@ -837,7 +837,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
|
|||||||
++LOG_OCCURRENCES; \
|
++LOG_OCCURRENCES; \
|
||||||
if (LOG_OCCURRENCES <= n) \
|
if (LOG_OCCURRENCES <= n) \
|
||||||
@ac_google_namespace@::LogMessage( \
|
@ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::severity, LOG_OCCURRENCES, \
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, LOG_OCCURRENCES, \
|
||||||
&what_to_do).stream()
|
&what_to_do).stream()
|
||||||
|
|
||||||
namespace glog_internal_namespace_ {
|
namespace glog_internal_namespace_ {
|
||||||
@ -851,7 +851,7 @@ struct CrashReason;
|
|||||||
typedef @ac_google_namespace@::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
|
typedef @ac_google_namespace@::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
|
||||||
|
|
||||||
#define LOG_EVERY_N(severity, n) \
|
#define LOG_EVERY_N(severity, n) \
|
||||||
GOOGLE_GLOG_COMPILE_ASSERT(@ac_google_namespace@::severity < \
|
GOOGLE_GLOG_COMPILE_ASSERT(@ac_google_namespace@::GLOG_ ## severity < \
|
||||||
@ac_google_namespace@::NUM_SEVERITIES, \
|
@ac_google_namespace@::NUM_SEVERITIES, \
|
||||||
INVALID_REQUESTED_LOG_SEVERITY); \
|
INVALID_REQUESTED_LOG_SEVERITY); \
|
||||||
SOME_KIND_OF_LOG_EVERY_N(severity, (n), @ac_google_namespace@::LogMessage::SendToLog)
|
SOME_KIND_OF_LOG_EVERY_N(severity, (n), @ac_google_namespace@::LogMessage::SendToLog)
|
||||||
@ -871,6 +871,27 @@ struct CrashReason;
|
|||||||
// We want the special COUNTER value available for LOG_EVERY_X()'ed messages
|
// We want the special COUNTER value available for LOG_EVERY_X()'ed messages
|
||||||
enum PRIVATE_Counter {COUNTER};
|
enum PRIVATE_Counter {COUNTER};
|
||||||
|
|
||||||
|
#ifdef GLOG_NO_ABBREVIATED_SEVERITIES
|
||||||
|
// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
|
||||||
|
// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us
|
||||||
|
// to keep using this syntax, we define this macro to do the same thing
|
||||||
|
// as COMPACT_GOOGLE_LOG_ERROR.
|
||||||
|
#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR
|
||||||
|
#define SYSLOG_0 SYSLOG_ERROR
|
||||||
|
#define LOG_TO_STRING_0 LOG_TO_STRING_ERROR
|
||||||
|
// Needed for LOG_IS_ON(ERROR).
|
||||||
|
const LogSeverity GLOG_0 = GLOG_ERROR;
|
||||||
|
#else
|
||||||
|
// Users may include windows.h after logging.h without
|
||||||
|
// GLOG_NO_ABBREVIATED_SEVERITIES nor WIN32_LEAN_AND_MEAN.
|
||||||
|
// For this case, we cannot detect if ERROR is defined before users
|
||||||
|
// actually use ERROR. Let's make an undefined symbol to warn users.
|
||||||
|
# define GLOG_ERROR_MSG ERROR_macro_is_defined_Define_GLOG_NO_ABBREVIATED_SEVERITIES_before_including_logging_h_See_the_document_for_detail
|
||||||
|
# define COMPACT_GOOGLE_LOG_0 GLOG_ERROR_MSG
|
||||||
|
# define SYSLOG_0 GLOG_ERROR_MSG
|
||||||
|
# define LOG_TO_STRING_0 GLOG_ERROR_MSG
|
||||||
|
# define GLOG_0 GLOG_ERROR_MSG
|
||||||
|
#endif
|
||||||
|
|
||||||
// Plus some debug-logging macros that get compiled to nothing for production
|
// Plus some debug-logging macros that get compiled to nothing for production
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,7 @@
|
|||||||
// I0821 211317 file.cc:142] RAW: status is 20
|
// I0821 211317 file.cc:142] RAW: status is 20
|
||||||
#define RAW_LOG(severity, ...) \
|
#define RAW_LOG(severity, ...) \
|
||||||
do { \
|
do { \
|
||||||
switch (@ac_google_namespace@::severity) { \
|
switch (@ac_google_namespace@::GLOG_ ## severity) { \
|
||||||
case 0: \
|
case 0: \
|
||||||
RAW_LOG_INFO(__VA_ARGS__); \
|
RAW_LOG_INFO(__VA_ARGS__); \
|
||||||
break; \
|
break; \
|
||||||
@ -100,28 +100,28 @@
|
|||||||
#endif // STRIP_LOG == 0
|
#endif // STRIP_LOG == 0
|
||||||
|
|
||||||
#if STRIP_LOG == 0
|
#if STRIP_LOG == 0
|
||||||
#define RAW_LOG_INFO(...) @ac_google_namespace@::RawLog__(@ac_google_namespace@::INFO, \
|
#define RAW_LOG_INFO(...) @ac_google_namespace@::RawLog__(@ac_google_namespace@::GLOG_INFO, \
|
||||||
__FILE__, __LINE__, __VA_ARGS__)
|
__FILE__, __LINE__, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define RAW_LOG_INFO(...) @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__)
|
#define RAW_LOG_INFO(...) @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__)
|
||||||
#endif // STRIP_LOG == 0
|
#endif // STRIP_LOG == 0
|
||||||
|
|
||||||
#if STRIP_LOG <= 1
|
#if STRIP_LOG <= 1
|
||||||
#define RAW_LOG_WARNING(...) @ac_google_namespace@::RawLog__(@ac_google_namespace@::WARNING, \
|
#define RAW_LOG_WARNING(...) @ac_google_namespace@::RawLog__(@ac_google_namespace@::GLOG_WARNING, \
|
||||||
__FILE__, __LINE__, __VA_ARGS__)
|
__FILE__, __LINE__, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define RAW_LOG_WARNING(...) @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__)
|
#define RAW_LOG_WARNING(...) @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__)
|
||||||
#endif // STRIP_LOG <= 1
|
#endif // STRIP_LOG <= 1
|
||||||
|
|
||||||
#if STRIP_LOG <= 2
|
#if STRIP_LOG <= 2
|
||||||
#define RAW_LOG_ERROR(...) @ac_google_namespace@::RawLog__(@ac_google_namespace@::ERROR, \
|
#define RAW_LOG_ERROR(...) @ac_google_namespace@::RawLog__(@ac_google_namespace@::GLOG_ERROR, \
|
||||||
__FILE__, __LINE__, __VA_ARGS__)
|
__FILE__, __LINE__, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define RAW_LOG_ERROR(...) @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__)
|
#define RAW_LOG_ERROR(...) @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__)
|
||||||
#endif // STRIP_LOG <= 2
|
#endif // STRIP_LOG <= 2
|
||||||
|
|
||||||
#if STRIP_LOG <= 3
|
#if STRIP_LOG <= 3
|
||||||
#define RAW_LOG_FATAL(...) @ac_google_namespace@::RawLog__(@ac_google_namespace@::FATAL, \
|
#define RAW_LOG_FATAL(...) @ac_google_namespace@::RawLog__(@ac_google_namespace@::GLOG_FATAL, \
|
||||||
__FILE__, __LINE__, __VA_ARGS__)
|
__FILE__, __LINE__, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define RAW_LOG_FATAL(...) \
|
#define RAW_LOG_FATAL(...) \
|
||||||
|
|||||||
@ -111,7 +111,7 @@ _END_GOOGLE_NAMESPACE_
|
|||||||
// The default is ERROR instead of FATAL so that users can see problems
|
// The default is ERROR instead of FATAL so that users can see problems
|
||||||
// when they run a program without having to look in another file.
|
// when they run a program without having to look in another file.
|
||||||
DEFINE_int32(stderrthreshold,
|
DEFINE_int32(stderrthreshold,
|
||||||
GOOGLE_NAMESPACE::ERROR,
|
GOOGLE_NAMESPACE::GLOG_ERROR,
|
||||||
"log messages at or above this level are copied to stderr in "
|
"log messages at or above this level are copied to stderr in "
|
||||||
"addition to logfiles. This flag obsoletes --alsologtostderr.");
|
"addition to logfiles. This flag obsoletes --alsologtostderr.");
|
||||||
|
|
||||||
@ -950,12 +950,12 @@ LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
|
|||||||
|
|
||||||
LogMessage::LogMessage(const char* file, int line,
|
LogMessage::LogMessage(const char* file, int line,
|
||||||
const CheckOpString& result) {
|
const CheckOpString& result) {
|
||||||
Init(file, line, FATAL, &LogMessage::SendToLog);
|
Init(file, line, GLOG_FATAL, &LogMessage::SendToLog);
|
||||||
stream() << "Check failed: " << (*result.str_) << " ";
|
stream() << "Check failed: " << (*result.str_) << " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage::LogMessage(const char* file, int line) {
|
LogMessage::LogMessage(const char* file, int line) {
|
||||||
Init(file, line, INFO, &LogMessage::SendToLog);
|
Init(file, line, GLOG_INFO, &LogMessage::SendToLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage::LogMessage(const char* file, int line, LogSeverity severity) {
|
LogMessage::LogMessage(const char* file, int line, LogSeverity severity) {
|
||||||
@ -986,7 +986,7 @@ void LogMessage::Init(const char* file,
|
|||||||
LogSeverity severity,
|
LogSeverity severity,
|
||||||
void (LogMessage::*send_method)()) {
|
void (LogMessage::*send_method)()) {
|
||||||
allocated_ = NULL;
|
allocated_ = NULL;
|
||||||
if (severity != FATAL || !exit_on_dfatal) {
|
if (severity != GLOG_FATAL || !exit_on_dfatal) {
|
||||||
allocated_ = new LogMessageData();
|
allocated_ = new LogMessageData();
|
||||||
data_ = allocated_;
|
data_ = allocated_;
|
||||||
data_->buf_ = new char[kMaxLogMessageLen+1];
|
data_->buf_ = new char[kMaxLogMessageLen+1];
|
||||||
@ -1137,7 +1137,7 @@ void ReprintFatalMessage() {
|
|||||||
// Also write to stderr
|
// Also write to stderr
|
||||||
WriteToStderr(fatal_message, n);
|
WriteToStderr(fatal_message, n);
|
||||||
}
|
}
|
||||||
LogDestination::LogToAllLogfiles(ERROR, fatal_time, fatal_message, n);
|
LogDestination::LogToAllLogfiles(GLOG_ERROR, fatal_time, fatal_message, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1195,7 +1195,7 @@ void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
|
|||||||
// If we log a FATAL message, flush all the log destinations, then toss
|
// If we log a FATAL message, flush all the log destinations, then toss
|
||||||
// a signal for others to catch. We leave the logs in a state that
|
// a signal for others to catch. We leave the logs in a state that
|
||||||
// someone else can use them (as long as they flush afterwards)
|
// someone else can use them (as long as they flush afterwards)
|
||||||
if (data_->severity_ == FATAL && exit_on_dfatal) {
|
if (data_->severity_ == GLOG_FATAL && exit_on_dfatal) {
|
||||||
if (data_->first_fatal_) {
|
if (data_->first_fatal_) {
|
||||||
// Store crash information so that it is accessible from within signal
|
// Store crash information so that it is accessible from within signal
|
||||||
// handlers that may be invoked later.
|
// handlers that may be invoked later.
|
||||||
@ -1783,7 +1783,7 @@ int posix_strerror_r(int err, char *buf, size_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogMessageFatal::LogMessageFatal(const char* file, int line) :
|
LogMessageFatal::LogMessageFatal(const char* file, int line) :
|
||||||
LogMessage(file, line, FATAL) {}
|
LogMessage(file, line, GLOG_FATAL) {}
|
||||||
|
|
||||||
LogMessageFatal::LogMessageFatal(const char* file, int line,
|
LogMessageFatal::LogMessageFatal(const char* file, int line,
|
||||||
const CheckOpString& result) :
|
const CheckOpString& result) :
|
||||||
|
|||||||
@ -201,7 +201,7 @@ int main(int argc, char **argv) {
|
|||||||
CaptureTestStderr();
|
CaptureTestStderr();
|
||||||
|
|
||||||
// re-emit early_stderr
|
// re-emit early_stderr
|
||||||
LogMessage("dummy", LogMessage::kNoLogPrefix, INFO).stream() << early_stderr;
|
LogMessage("dummy", LogMessage::kNoLogPrefix, GLOG_INFO).stream() << early_stderr;
|
||||||
|
|
||||||
TestLogging(true);
|
TestLogging(true);
|
||||||
TestRawLogging();
|
TestRawLogging();
|
||||||
@ -234,9 +234,9 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TestLogging(bool check_counts) {
|
void TestLogging(bool check_counts) {
|
||||||
int64 base_num_infos = LogMessage::num_messages(INFO);
|
int64 base_num_infos = LogMessage::num_messages(GLOG_INFO);
|
||||||
int64 base_num_warning = LogMessage::num_messages(WARNING);
|
int64 base_num_warning = LogMessage::num_messages(GLOG_WARNING);
|
||||||
int64 base_num_errors = LogMessage::num_messages(ERROR);
|
int64 base_num_errors = LogMessage::num_messages(GLOG_ERROR);
|
||||||
|
|
||||||
LOG(INFO) << string("foo ") << "bar " << 10 << ' ' << 3.4;
|
LOG(INFO) << string("foo ") << "bar " << 10 << ' ' << 3.4;
|
||||||
for ( int i = 0; i < 10; ++i ) {
|
for ( int i = 0; i < 10; ++i ) {
|
||||||
@ -266,12 +266,12 @@ void TestLogging(bool check_counts) {
|
|||||||
LOG(ERROR) << string("foo") << ' '<< j << ' ' << setw(10) << j << " "
|
LOG(ERROR) << string("foo") << ' '<< j << ' ' << setw(10) << j << " "
|
||||||
<< setw(1) << hex << j;
|
<< setw(1) << hex << j;
|
||||||
|
|
||||||
LogMessage("foo", LogMessage::kNoLogPrefix, INFO).stream() << "no prefix";
|
LogMessage("foo", LogMessage::kNoLogPrefix, GLOG_INFO).stream() << "no prefix";
|
||||||
|
|
||||||
if (check_counts) {
|
if (check_counts) {
|
||||||
CHECK_EQ(base_num_infos + 14, LogMessage::num_messages(INFO));
|
CHECK_EQ(base_num_infos + 14, LogMessage::num_messages(GLOG_INFO));
|
||||||
CHECK_EQ(base_num_warning + 3, LogMessage::num_messages(WARNING));
|
CHECK_EQ(base_num_warning + 3, LogMessage::num_messages(GLOG_WARNING));
|
||||||
CHECK_EQ(base_num_errors + 15, LogMessage::num_messages(ERROR));
|
CHECK_EQ(base_num_errors + 15, LogMessage::num_messages(GLOG_ERROR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,16 +416,16 @@ void LogWithLevels(int v, int severity, bool err, bool alsoerr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TestLoggingLevels() {
|
void TestLoggingLevels() {
|
||||||
LogWithLevels(0, INFO, false, false);
|
LogWithLevels(0, GLOG_INFO, false, false);
|
||||||
LogWithLevels(1, INFO, false, false);
|
LogWithLevels(1, GLOG_INFO, false, false);
|
||||||
LogWithLevels(-1, INFO, false, false);
|
LogWithLevels(-1, GLOG_INFO, false, false);
|
||||||
LogWithLevels(0, WARNING, false, false);
|
LogWithLevels(0, GLOG_WARNING, false, false);
|
||||||
LogWithLevels(0, ERROR, false, false);
|
LogWithLevels(0, GLOG_ERROR, false, false);
|
||||||
LogWithLevels(0, FATAL, false, false);
|
LogWithLevels(0, GLOG_FATAL, false, false);
|
||||||
LogWithLevels(0, FATAL, true, false);
|
LogWithLevels(0, GLOG_FATAL, true, false);
|
||||||
LogWithLevels(0, FATAL, false, true);
|
LogWithLevels(0, GLOG_FATAL, false, true);
|
||||||
LogWithLevels(1, WARNING, false, false);
|
LogWithLevels(1, GLOG_WARNING, false, false);
|
||||||
LogWithLevels(1, FATAL, false, true);
|
LogWithLevels(1, GLOG_FATAL, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DeathRawCHECK, logging) {
|
TEST(DeathRawCHECK, logging) {
|
||||||
@ -508,7 +508,7 @@ void TestLogSink() {
|
|||||||
|
|
||||||
LOG(INFO) << "Captured by LOG_TO_SINK:";
|
LOG(INFO) << "Captured by LOG_TO_SINK:";
|
||||||
for (size_t i = 0; i < sink.errors.size(); ++i) {
|
for (size_t i = 0; i < sink.errors.size(); ++i) {
|
||||||
LogMessage("foo", LogMessage::kNoLogPrefix, INFO).stream()
|
LogMessage("foo", LogMessage::kNoLogPrefix, GLOG_INFO).stream()
|
||||||
<< sink.errors[i];
|
<< sink.errors[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -667,9 +667,9 @@ static void TestBasename() {
|
|||||||
const string dest = FLAGS_test_tmpdir + "/logging_test_basename";
|
const string dest = FLAGS_test_tmpdir + "/logging_test_basename";
|
||||||
DeleteFiles(dest + "*");
|
DeleteFiles(dest + "*");
|
||||||
|
|
||||||
SetLogDestination(INFO, dest.c_str());
|
SetLogDestination(GLOG_INFO, dest.c_str());
|
||||||
LOG(INFO) << "message to new base";
|
LOG(INFO) << "message to new base";
|
||||||
FlushLogFiles(INFO);
|
FlushLogFiles(GLOG_INFO);
|
||||||
|
|
||||||
CheckFile(dest, "message to new base");
|
CheckFile(dest, "message to new base");
|
||||||
|
|
||||||
@ -686,10 +686,10 @@ static void TestSymlink() {
|
|||||||
DeleteFiles(dest + "*");
|
DeleteFiles(dest + "*");
|
||||||
DeleteFiles(sym + "*");
|
DeleteFiles(sym + "*");
|
||||||
|
|
||||||
SetLogSymlink(INFO, "symlinkbase");
|
SetLogSymlink(GLOG_INFO, "symlinkbase");
|
||||||
SetLogDestination(INFO, dest.c_str());
|
SetLogDestination(GLOG_INFO, dest.c_str());
|
||||||
LOG(INFO) << "message to new symlink";
|
LOG(INFO) << "message to new symlink";
|
||||||
FlushLogFiles(INFO);
|
FlushLogFiles(GLOG_INFO);
|
||||||
CheckFile(sym, "message to new symlink");
|
CheckFile(sym, "message to new symlink");
|
||||||
|
|
||||||
DeleteFiles(dest + "*");
|
DeleteFiles(dest + "*");
|
||||||
@ -702,10 +702,10 @@ static void TestExtension() {
|
|||||||
string dest = FLAGS_test_tmpdir + "/logging_test_extension";
|
string dest = FLAGS_test_tmpdir + "/logging_test_extension";
|
||||||
DeleteFiles(dest + "*");
|
DeleteFiles(dest + "*");
|
||||||
|
|
||||||
SetLogDestination(INFO, dest.c_str());
|
SetLogDestination(GLOG_INFO, dest.c_str());
|
||||||
SetLogFilenameExtension("specialextension");
|
SetLogFilenameExtension("specialextension");
|
||||||
LOG(INFO) << "message to new extension";
|
LOG(INFO) << "message to new extension";
|
||||||
FlushLogFiles(INFO);
|
FlushLogFiles(GLOG_INFO);
|
||||||
CheckFile(dest, "message to new extension");
|
CheckFile(dest, "message to new extension");
|
||||||
|
|
||||||
// Check that file name ends with extension
|
// Check that file name ends with extension
|
||||||
@ -738,11 +738,11 @@ static void TestWrapper() {
|
|||||||
fprintf(stderr, "==== Test log wrapper\n");
|
fprintf(stderr, "==== Test log wrapper\n");
|
||||||
|
|
||||||
MyLogger my_logger;
|
MyLogger my_logger;
|
||||||
base::Logger* old_logger = base::GetLogger(INFO);
|
base::Logger* old_logger = base::GetLogger(GLOG_INFO);
|
||||||
base::SetLogger(INFO, &my_logger);
|
base::SetLogger(GLOG_INFO, &my_logger);
|
||||||
LOG(INFO) << "Send to wrapped logger";
|
LOG(INFO) << "Send to wrapped logger";
|
||||||
FlushLogFiles(INFO);
|
FlushLogFiles(GLOG_INFO);
|
||||||
base::SetLogger(INFO, old_logger);
|
base::SetLogger(GLOG_INFO, old_logger);
|
||||||
|
|
||||||
CHECK(strstr(my_logger.data.c_str(), "Send to wrapped logger") != NULL);
|
CHECK(strstr(my_logger.data.c_str(), "Send to wrapped logger") != NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -151,7 +151,7 @@ void RawLog__(LogSeverity severity, const char* file, int line,
|
|||||||
// libc (to side-step any libc interception).
|
// libc (to side-step any libc interception).
|
||||||
// We write just once to avoid races with other invocations of RawLog__.
|
// We write just once to avoid races with other invocations of RawLog__.
|
||||||
safe_write(STDERR_FILENO, buffer, strlen(buffer));
|
safe_write(STDERR_FILENO, buffer, strlen(buffer));
|
||||||
if (severity == FATAL) {
|
if (severity == GLOG_FATAL) {
|
||||||
if (!sync_val_compare_and_swap(&crashed, false, true)) {
|
if (!sync_val_compare_and_swap(&crashed, false, true)) {
|
||||||
crash_reason.filename = file;
|
crash_reason.filename = file;
|
||||||
crash_reason.line_number = line;
|
crash_reason.line_number = line;
|
||||||
|
|||||||
@ -48,7 +48,15 @@
|
|||||||
// you ever need to change their values or add a new severity.
|
// you ever need to change their values or add a new severity.
|
||||||
typedef int LogSeverity;
|
typedef int LogSeverity;
|
||||||
|
|
||||||
const int INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3, NUM_SEVERITIES = 4;
|
const int GLOG_INFO = 0, GLOG_WARNING = 1, GLOG_ERROR = 2, GLOG_FATAL = 3,
|
||||||
|
NUM_SEVERITIES = 4;
|
||||||
|
#ifndef GLOG_NO_ABBREVIATED_SEVERITIES
|
||||||
|
# ifdef ERROR
|
||||||
|
# error ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail.
|
||||||
|
# endif
|
||||||
|
const int INFO = GLOG_INFO, WARNING = GLOG_WARNING,
|
||||||
|
ERROR = GLOG_ERROR, FATAL = GLOG_FATAL;
|
||||||
|
#endif
|
||||||
|
|
||||||
// DFATAL is FATAL in debug mode, ERROR in normal mode
|
// DFATAL is FATAL in debug mode, ERROR in normal mode
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
|
|||||||
@ -372,7 +372,7 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
#define COMPACT_GOOGLE_LOG_INFO google::LogMessage( \
|
#define COMPACT_GOOGLE_LOG_INFO google::LogMessage( \
|
||||||
__FILE__, __LINE__)
|
__FILE__, __LINE__)
|
||||||
#define LOG_TO_STRING_INFO(message) google::LogMessage( \
|
#define LOG_TO_STRING_INFO(message) google::LogMessage( \
|
||||||
__FILE__, __LINE__, google::INFO, message)
|
__FILE__, __LINE__, google::GLOG_INFO, message)
|
||||||
#else
|
#else
|
||||||
#define COMPACT_GOOGLE_LOG_INFO google::NullStream()
|
#define COMPACT_GOOGLE_LOG_INFO google::NullStream()
|
||||||
#define LOG_TO_STRING_INFO(message) google::NullStream()
|
#define LOG_TO_STRING_INFO(message) google::NullStream()
|
||||||
@ -380,9 +380,9 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
|
|
||||||
#if GOOGLE_STRIP_LOG <= 1
|
#if GOOGLE_STRIP_LOG <= 1
|
||||||
#define COMPACT_GOOGLE_LOG_WARNING google::LogMessage( \
|
#define COMPACT_GOOGLE_LOG_WARNING google::LogMessage( \
|
||||||
__FILE__, __LINE__, google::WARNING)
|
__FILE__, __LINE__, google::GLOG_WARNING)
|
||||||
#define LOG_TO_STRING_WARNING(message) google::LogMessage( \
|
#define LOG_TO_STRING_WARNING(message) google::LogMessage( \
|
||||||
__FILE__, __LINE__, google::WARNING, message)
|
__FILE__, __LINE__, google::GLOG_WARNING, message)
|
||||||
#else
|
#else
|
||||||
#define COMPACT_GOOGLE_LOG_WARNING google::NullStream()
|
#define COMPACT_GOOGLE_LOG_WARNING google::NullStream()
|
||||||
#define LOG_TO_STRING_WARNING(message) google::NullStream()
|
#define LOG_TO_STRING_WARNING(message) google::NullStream()
|
||||||
@ -390,9 +390,9 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
|
|
||||||
#if GOOGLE_STRIP_LOG <= 2
|
#if GOOGLE_STRIP_LOG <= 2
|
||||||
#define COMPACT_GOOGLE_LOG_ERROR google::LogMessage( \
|
#define COMPACT_GOOGLE_LOG_ERROR google::LogMessage( \
|
||||||
__FILE__, __LINE__, google::ERROR)
|
__FILE__, __LINE__, google::GLOG_ERROR)
|
||||||
#define LOG_TO_STRING_ERROR(message) google::LogMessage( \
|
#define LOG_TO_STRING_ERROR(message) google::LogMessage( \
|
||||||
__FILE__, __LINE__, google::ERROR, message)
|
__FILE__, __LINE__, google::GLOG_ERROR, message)
|
||||||
#else
|
#else
|
||||||
#define COMPACT_GOOGLE_LOG_ERROR google::NullStream()
|
#define COMPACT_GOOGLE_LOG_ERROR google::NullStream()
|
||||||
#define LOG_TO_STRING_ERROR(message) google::NullStream()
|
#define LOG_TO_STRING_ERROR(message) google::NullStream()
|
||||||
@ -402,7 +402,7 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
#define COMPACT_GOOGLE_LOG_FATAL google::LogMessageFatal( \
|
#define COMPACT_GOOGLE_LOG_FATAL google::LogMessageFatal( \
|
||||||
__FILE__, __LINE__)
|
__FILE__, __LINE__)
|
||||||
#define LOG_TO_STRING_FATAL(message) google::LogMessage( \
|
#define LOG_TO_STRING_FATAL(message) google::LogMessage( \
|
||||||
__FILE__, __LINE__, google::FATAL, message)
|
__FILE__, __LINE__, google::GLOG_FATAL, message)
|
||||||
#else
|
#else
|
||||||
#define COMPACT_GOOGLE_LOG_FATAL google::NullStreamFatal()
|
#define COMPACT_GOOGLE_LOG_FATAL google::NullStreamFatal()
|
||||||
#define LOG_TO_STRING_FATAL(message) google::NullStreamFatal()
|
#define LOG_TO_STRING_FATAL(message) google::NullStreamFatal()
|
||||||
@ -414,32 +414,32 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
|
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
|
||||||
#elif GOOGLE_STRIP_LOG <= 3
|
#elif GOOGLE_STRIP_LOG <= 3
|
||||||
#define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \
|
#define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \
|
||||||
__FILE__, __LINE__, google::FATAL)
|
__FILE__, __LINE__, google::GLOG_FATAL)
|
||||||
#else
|
#else
|
||||||
#define COMPACT_GOOGLE_LOG_DFATAL google::NullStreamFatal()
|
#define COMPACT_GOOGLE_LOG_DFATAL google::NullStreamFatal()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::INFO, counter, &google::LogMessage::SendToLog)
|
#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, &google::LogMessage::SendToLog)
|
||||||
#define SYSLOG_INFO(counter) \
|
#define SYSLOG_INFO(counter) \
|
||||||
google::LogMessage(__FILE__, __LINE__, google::INFO, counter, \
|
google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, \
|
||||||
&google::LogMessage::SendToSyslogAndLog)
|
&google::LogMessage::SendToSyslogAndLog)
|
||||||
#define GOOGLE_LOG_WARNING(counter) \
|
#define GOOGLE_LOG_WARNING(counter) \
|
||||||
google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \
|
google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \
|
||||||
&google::LogMessage::SendToLog)
|
&google::LogMessage::SendToLog)
|
||||||
#define SYSLOG_WARNING(counter) \
|
#define SYSLOG_WARNING(counter) \
|
||||||
google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \
|
google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \
|
||||||
&google::LogMessage::SendToSyslogAndLog)
|
&google::LogMessage::SendToSyslogAndLog)
|
||||||
#define GOOGLE_LOG_ERROR(counter) \
|
#define GOOGLE_LOG_ERROR(counter) \
|
||||||
google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \
|
google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \
|
||||||
&google::LogMessage::SendToLog)
|
&google::LogMessage::SendToLog)
|
||||||
#define SYSLOG_ERROR(counter) \
|
#define SYSLOG_ERROR(counter) \
|
||||||
google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \
|
google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \
|
||||||
&google::LogMessage::SendToSyslogAndLog)
|
&google::LogMessage::SendToSyslogAndLog)
|
||||||
#define GOOGLE_LOG_FATAL(counter) \
|
#define GOOGLE_LOG_FATAL(counter) \
|
||||||
google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \
|
google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \
|
||||||
&google::LogMessage::SendToLog)
|
&google::LogMessage::SendToLog)
|
||||||
#define SYSLOG_FATAL(counter) \
|
#define SYSLOG_FATAL(counter) \
|
||||||
google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \
|
google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \
|
||||||
&google::LogMessage::SendToSyslogAndLog)
|
&google::LogMessage::SendToSyslogAndLog)
|
||||||
#define GOOGLE_LOG_DFATAL(counter) \
|
#define GOOGLE_LOG_DFATAL(counter) \
|
||||||
google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
|
google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
|
||||||
@ -458,7 +458,7 @@ DECLARE_bool(stop_logging_if_full_disk);
|
|||||||
FORMAT_MESSAGE_FROM_SYSTEM, \
|
FORMAT_MESSAGE_FROM_SYSTEM, \
|
||||||
0, result, 0, msg, 100, NULL); \
|
0, result, 0, msg, 100, NULL); \
|
||||||
if (message_length > 0) { \
|
if (message_length > 0) { \
|
||||||
google::LogMessage(__FILE__, __LINE__, ERROR, 0, \
|
google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, 0, \
|
||||||
&google::LogMessage::SendToLog).stream() << message; \
|
&google::LogMessage::SendToLog).stream() << message; \
|
||||||
LocalFree(message); \
|
LocalFree(message); \
|
||||||
} \
|
} \
|
||||||
@ -505,12 +505,12 @@ class LogSink; // defined below
|
|||||||
#define LOG_TO_SINK(sink, severity) \
|
#define LOG_TO_SINK(sink, severity) \
|
||||||
google::LogMessage( \
|
google::LogMessage( \
|
||||||
__FILE__, __LINE__, \
|
__FILE__, __LINE__, \
|
||||||
google::severity, \
|
google::GLOG_ ## severity, \
|
||||||
static_cast<google::LogSink*>(sink), true).stream()
|
static_cast<google::LogSink*>(sink), true).stream()
|
||||||
#define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity) \
|
#define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity) \
|
||||||
google::LogMessage( \
|
google::LogMessage( \
|
||||||
__FILE__, __LINE__, \
|
__FILE__, __LINE__, \
|
||||||
google::severity, \
|
google::GLOG_ ## severity, \
|
||||||
static_cast<google::LogSink*>(sink), false).stream()
|
static_cast<google::LogSink*>(sink), false).stream()
|
||||||
|
|
||||||
// If a non-NULL string pointer is given, we write this message to that string.
|
// If a non-NULL string pointer is given, we write this message to that string.
|
||||||
@ -775,7 +775,7 @@ DECLARE_CHECK_STROP_IMPL(strcasecmp, false)
|
|||||||
|
|
||||||
#define GOOGLE_PLOG(severity, counter) \
|
#define GOOGLE_PLOG(severity, counter) \
|
||||||
google::ErrnoLogMessage( \
|
google::ErrnoLogMessage( \
|
||||||
__FILE__, __LINE__, google::severity, counter, \
|
__FILE__, __LINE__, google::GLOG_ ## severity, counter, \
|
||||||
&google::LogMessage::SendToLog)
|
&google::LogMessage::SendToLog)
|
||||||
|
|
||||||
#define PLOG_IF(severity, condition) \
|
#define PLOG_IF(severity, condition) \
|
||||||
@ -814,7 +814,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
|
|||||||
if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
|
if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
|
||||||
if (LOG_OCCURRENCES_MOD_N == 1) \
|
if (LOG_OCCURRENCES_MOD_N == 1) \
|
||||||
google::LogMessage( \
|
google::LogMessage( \
|
||||||
__FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
|
__FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
|
||||||
&what_to_do).stream()
|
&what_to_do).stream()
|
||||||
|
|
||||||
#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
|
#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
|
||||||
@ -823,7 +823,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
|
|||||||
if (condition && \
|
if (condition && \
|
||||||
((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \
|
((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \
|
||||||
google::LogMessage( \
|
google::LogMessage( \
|
||||||
__FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
|
__FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
|
||||||
&what_to_do).stream()
|
&what_to_do).stream()
|
||||||
|
|
||||||
#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
|
#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
|
||||||
@ -832,7 +832,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
|
|||||||
if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
|
if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
|
||||||
if (LOG_OCCURRENCES_MOD_N == 1) \
|
if (LOG_OCCURRENCES_MOD_N == 1) \
|
||||||
google::ErrnoLogMessage( \
|
google::ErrnoLogMessage( \
|
||||||
__FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
|
__FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
|
||||||
&what_to_do).stream()
|
&what_to_do).stream()
|
||||||
|
|
||||||
#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
|
#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
|
||||||
@ -841,7 +841,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
|
|||||||
++LOG_OCCURRENCES; \
|
++LOG_OCCURRENCES; \
|
||||||
if (LOG_OCCURRENCES <= n) \
|
if (LOG_OCCURRENCES <= n) \
|
||||||
google::LogMessage( \
|
google::LogMessage( \
|
||||||
__FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
|
__FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
|
||||||
&what_to_do).stream()
|
&what_to_do).stream()
|
||||||
|
|
||||||
namespace glog_internal_namespace_ {
|
namespace glog_internal_namespace_ {
|
||||||
@ -855,7 +855,7 @@ struct CrashReason;
|
|||||||
typedef google::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
|
typedef google::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
|
||||||
|
|
||||||
#define LOG_EVERY_N(severity, n) \
|
#define LOG_EVERY_N(severity, n) \
|
||||||
GOOGLE_GLOG_COMPILE_ASSERT(google::severity < \
|
GOOGLE_GLOG_COMPILE_ASSERT(google::GLOG_ ## severity < \
|
||||||
google::NUM_SEVERITIES, \
|
google::NUM_SEVERITIES, \
|
||||||
INVALID_REQUESTED_LOG_SEVERITY); \
|
INVALID_REQUESTED_LOG_SEVERITY); \
|
||||||
SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
|
SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
|
||||||
@ -875,6 +875,27 @@ struct CrashReason;
|
|||||||
// We want the special COUNTER value available for LOG_EVERY_X()'ed messages
|
// We want the special COUNTER value available for LOG_EVERY_X()'ed messages
|
||||||
enum PRIVATE_Counter {COUNTER};
|
enum PRIVATE_Counter {COUNTER};
|
||||||
|
|
||||||
|
#ifdef GLOG_NO_ABBREVIATED_SEVERITIES
|
||||||
|
// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
|
||||||
|
// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us
|
||||||
|
// to keep using this syntax, we define this macro to do the same thing
|
||||||
|
// as COMPACT_GOOGLE_LOG_ERROR.
|
||||||
|
#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR
|
||||||
|
#define SYSLOG_0 SYSLOG_ERROR
|
||||||
|
#define LOG_TO_STRING_0 LOG_TO_STRING_ERROR
|
||||||
|
// Needed for LOG_IS_ON(ERROR).
|
||||||
|
const LogSeverity GLOG_0 = GLOG_ERROR;
|
||||||
|
#else
|
||||||
|
// Users may include windows.h after logging.h without
|
||||||
|
// GLOG_NO_ABBREVIATED_SEVERITIES nor WIN32_LEAN_AND_MEAN.
|
||||||
|
// For this case, we cannot detect if ERROR is defined before users
|
||||||
|
// actually use ERROR. Let's make an undefined symbol to warn users.
|
||||||
|
# define GLOG_ERROR_MSG ERROR_macro_is_defined_Define_GLOG_NO_ABBREVIATED_SEVERITIES_before_including_logging_h_See_the_document_for_detail
|
||||||
|
# define COMPACT_GOOGLE_LOG_0 GLOG_ERROR_MSG
|
||||||
|
# define SYSLOG_0 GLOG_ERROR_MSG
|
||||||
|
# define LOG_TO_STRING_0 GLOG_ERROR_MSG
|
||||||
|
# define GLOG_0 GLOG_ERROR_MSG
|
||||||
|
#endif
|
||||||
|
|
||||||
// Plus some debug-logging macros that get compiled to nothing for production
|
// Plus some debug-logging macros that get compiled to nothing for production
|
||||||
|
|
||||||
|
|||||||
@ -72,7 +72,7 @@ namespace google {
|
|||||||
// I0821 211317 file.cc:142] RAW: status is 20
|
// I0821 211317 file.cc:142] RAW: status is 20
|
||||||
#define RAW_LOG(severity, ...) \
|
#define RAW_LOG(severity, ...) \
|
||||||
do { \
|
do { \
|
||||||
switch (google::severity) { \
|
switch (google::GLOG_ ## severity) { \
|
||||||
case 0: \
|
case 0: \
|
||||||
RAW_LOG_INFO(__VA_ARGS__); \
|
RAW_LOG_INFO(__VA_ARGS__); \
|
||||||
break; \
|
break; \
|
||||||
@ -104,28 +104,28 @@ namespace google {
|
|||||||
#endif // STRIP_LOG == 0
|
#endif // STRIP_LOG == 0
|
||||||
|
|
||||||
#if STRIP_LOG == 0
|
#if STRIP_LOG == 0
|
||||||
#define RAW_LOG_INFO(...) google::RawLog__(google::INFO, \
|
#define RAW_LOG_INFO(...) google::RawLog__(google::GLOG_INFO, \
|
||||||
__FILE__, __LINE__, __VA_ARGS__)
|
__FILE__, __LINE__, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__)
|
#define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__)
|
||||||
#endif // STRIP_LOG == 0
|
#endif // STRIP_LOG == 0
|
||||||
|
|
||||||
#if STRIP_LOG <= 1
|
#if STRIP_LOG <= 1
|
||||||
#define RAW_LOG_WARNING(...) google::RawLog__(google::WARNING, \
|
#define RAW_LOG_WARNING(...) google::RawLog__(google::GLOG_WARNING, \
|
||||||
__FILE__, __LINE__, __VA_ARGS__)
|
__FILE__, __LINE__, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__)
|
#define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__)
|
||||||
#endif // STRIP_LOG <= 1
|
#endif // STRIP_LOG <= 1
|
||||||
|
|
||||||
#if STRIP_LOG <= 2
|
#if STRIP_LOG <= 2
|
||||||
#define RAW_LOG_ERROR(...) google::RawLog__(google::ERROR, \
|
#define RAW_LOG_ERROR(...) google::RawLog__(google::GLOG_ERROR, \
|
||||||
__FILE__, __LINE__, __VA_ARGS__)
|
__FILE__, __LINE__, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__)
|
#define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__)
|
||||||
#endif // STRIP_LOG <= 2
|
#endif // STRIP_LOG <= 2
|
||||||
|
|
||||||
#if STRIP_LOG <= 3
|
#if STRIP_LOG <= 3
|
||||||
#define RAW_LOG_FATAL(...) google::RawLog__(google::FATAL, \
|
#define RAW_LOG_FATAL(...) google::RawLog__(google::GLOG_FATAL, \
|
||||||
__FILE__, __LINE__, __VA_ARGS__)
|
__FILE__, __LINE__, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define RAW_LOG_FATAL(...) \
|
#define RAW_LOG_FATAL(...) \
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user