From 6febec361e73860cc77d9cb0c6c14013c0e36ef0 Mon Sep 17 00:00:00 2001 From: Date: Wed, 11 Jan 2012 09:17:04 +0000 Subject: [PATCH] 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 --- doc/glog.html | 44 ++++++++++++++++++++- src/glog/log_severity.h | 10 ++++- src/glog/logging.h.in | 69 +++++++++++++++++++++------------ src/glog/raw_logging.h.in | 10 ++--- src/logging.cc | 18 ++++----- src/logging_unittest.cc | 60 ++++++++++++++-------------- src/raw_logging.cc | 2 +- src/windows/glog/log_severity.h | 10 ++++- src/windows/glog/logging.h | 69 +++++++++++++++++++++------------ src/windows/glog/raw_logging.h | 10 ++--- 10 files changed, 200 insertions(+), 102 deletions(-) diff --git a/doc/glog.html b/doc/glog.html index a2d093d..a104659 100644 --- a/doc/glog.html +++ b/doc/glog.html @@ -527,8 +527,48 @@ all log messages associated with VLOGs as well as

Notes for Windows users

Google glog defines a severity level ERROR, which is -also defined in windows.h -There are two known workarounds to avoid this conflict: +also defined in windows.h . You can make glog not define +INFO, WARNING, ERROR, +and FATAL by defining +GLOG_NO_ABBREVIATED_SEVERITIES before +including glog/logging.h . Even with this macro, you can +still use the iostream like logging facilities: + +

+  #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";
+
+ +

+However, you cannot +use INFO, WARNING, ERROR, +and FATAL anymore for functions defined +in glog/logging.h . + +

+  #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);
+
+ +

+If you don't need ERROR defined +by windows.h, there are a couple of more workarounds +which sometimes don't work: