X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=doc%2Fglog.html;h=8b200bacaf7187e297668c74d1138f3fe3313e3d;hb=a2a66f611c1c5ac02d96df88352b2ce11183cdcd;hp=9fe2e1fe6205fd903bfe41eb13a0e0c22d4c055e;hpb=cb350102153cf25db31903b103ee6bf003cfa7c2;p=platform%2Fupstream%2Fglog.git diff --git a/doc/glog.html b/doc/glog.html index 9fe2e1f..8b200ba 100644 --- a/doc/glog.html +++ b/doc/glog.html @@ -168,6 +168,25 @@ See also the section about verbose logging.
There are some other flags defined in logging.cc. Please grep the source code for "DEFINE_" to see a complete list of all flags. +
You can also modify flag values in your program by modifying global
+variables FLAGS_*
. Most settings start working
+immediately after you update FLAGS_*
. The exceptions are
+the flags related to destination files. For example, you might want to
+set FLAGS_log_dir
before
+calling google::InitGoogleLogging
. Here is an example:
+
+
+ LOG(INFO) << "file"; + // Most flags work immediately after updating values. + FLAGS_logtostderr = 1; + LOG(INFO) << "stderr"; + FLAGS_logtostderr = 0; + // This won't change the log destination. If you want to set this + // value, you should do this before google::InitGoogleLogging . + FLAGS_log_dir = "/some/log/directory"; + LOG(INFO) << "the same file"; ++
Sometimes, you may only want to log a message under certain @@ -186,19 +205,19 @@ a message at certain intervals. This kind of logging is most useful for informational messages.
- LOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie"; + LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
The above line outputs a log messages on the 1st, 11th,
21st, ... times it is executed. Note that the special
-COUNTER
value is used to identify which repetition is
+google::COUNTER
value is used to identify which repetition is
happening.
You can combine conditional and occasional logging with the following macro.
- LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << COUNTER + LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER << "th big cookie";@@ -206,11 +225,11 @@ following macro. the output to the first n occurrences:
- LOG_FIRST_N(INFO, 20) << "Got the " << COUNTER << "th cookie"; + LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie";
Outputs log messages for the first 20 times it is executed. Again,
-the COUNTER
identifier indicates which repetition is
+the google::COUNTER
identifier indicates which repetition is
happening.
GOOGLE_STRIP_LOG
to 1 or greater removes
all log messages associated with VLOG
s as well as
INFO
log statements.
+Google glog defines a severity level ERROR
, which is
+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:
+
+
WIN32_LEAN_AND_MEAN
or NOGDI
+ before you #include windows.h
.
+ ERROR
after you #include
+ windows.h
.
+See +this issue for more detail. +