Fix some syntax/HTML issues.
git-svn-id: https://google-glog.googlecode.com/svn/trunk@4 eb4d4688-79bd-11dd-afb4-1d65580434c0
This commit is contained in:
parent
13b587131b
commit
fc7c28797e
@ -96,7 +96,7 @@ in addition to log files.
|
|||||||
|
|
||||||
<h2><A NAME=flags>Setting Flags</A></h2>
|
<h2><A NAME=flags>Setting Flags</A></h2>
|
||||||
|
|
||||||
<p>Several flags influences glog's output behavior.
|
<p>Several flags influence glog's output behavior.
|
||||||
If the <a href="http://code.google.com/p/google-gflags/">Google
|
If the <a href="http://code.google.com/p/google-gflags/">Google
|
||||||
gflags library</a> is installed on your machine, the
|
gflags library</a> is installed on your machine, the
|
||||||
<code>configure</code> script (see the INSTALL file in the package for
|
<code>configure</code> script (see the INSTALL file in the package for
|
||||||
@ -168,7 +168,7 @@ conditions. You can use the following macros to perform conditional
|
|||||||
logging:
|
logging:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
The "Got lots of cookies" message is logged only when the variable
|
The "Got lots of cookies" message is logged only when the variable
|
||||||
@ -191,7 +191,7 @@ happening.
|
|||||||
following macro.
|
following macro.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << COUNTER
|
LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << COUNTER
|
||||||
<< "th big cookie";
|
<< "th big cookie";
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
@ -216,14 +216,11 @@ application due to excessive logging.
|
|||||||
<pre>
|
<pre>
|
||||||
DLOG(INFO) << "Found cookies";
|
DLOG(INFO) << "Found cookies";
|
||||||
|
|
||||||
DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
||||||
|
|
||||||
DLOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie";
|
DLOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie";
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>All "debug mode" logging is compiled away to nothing for non-debug mode
|
|
||||||
compiles.
|
|
||||||
|
|
||||||
<h2><A NAME=check>CHECK Macros</A></h2>
|
<h2><A NAME=check>CHECK Macros</A></h2>
|
||||||
|
|
||||||
<p>It is a good practice to check expected conditions in your program
|
<p>It is a good practice to check expected conditions in your program
|
||||||
@ -235,11 +232,11 @@ defined in the standard C library.
|
|||||||
<p><code>CHECK</code> aborts the application if a condition is not
|
<p><code>CHECK</code> aborts the application if a condition is not
|
||||||
true. Unlike <code>assert</code>, it is *not* controlled by
|
true. Unlike <code>assert</code>, it is *not* controlled by
|
||||||
<code>NDEBUG</code>, so the check will be executed regardless of
|
<code>NDEBUG</code>, so the check will be executed regardless of
|
||||||
compilation mode. Therefore, <code>fp->Write(x)</code> in the
|
compilation mode. Therefore, <code>fp->Write(x)</code> in the
|
||||||
following example is always executed:
|
following example is always executed:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
CHECK(fp->Write(x) == 4) << "Write failed!";
|
CHECK(fp->Write(x) == 4) << "Write failed!";
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>There are various helper macros for
|
<p>There are various helper macros for
|
||||||
@ -272,14 +269,14 @@ pointer and the other is NULL. To work around this, simply static_cast
|
|||||||
NULL to the type of the desired pointer.
|
NULL to the type of the desired pointer.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
CHECK_EQ(some_ptr, static_cast<SomeType*>(NULL));
|
CHECK_EQ(some_ptr, static_cast<SomeType*>(NULL));
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>Better yet, use the CHECK_NOTNULL macro:
|
<p>Better yet, use the CHECK_NOTNULL macro:
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
CHECK_NOTNULL(some_ptr);
|
CHECK_NOTNULL(some_ptr);
|
||||||
some_ptr->DoSomething();
|
some_ptr->DoSomething();
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>Since this macro returns the given pointer, this is very useful in
|
<p>Since this macro returns the given pointer, this is very useful in
|
||||||
@ -308,7 +305,7 @@ equal.
|
|||||||
<p>Note that both arguments may be temporary strings which are
|
<p>Note that both arguments may be temporary strings which are
|
||||||
destructed at the end of the current "full expression"
|
destructed at the end of the current "full expression"
|
||||||
(e.g., <code>CHECK_STREQ(Foo().c_str(), Bar().c_str())</code> where
|
(e.g., <code>CHECK_STREQ(Foo().c_str(), Bar().c_str())</code> where
|
||||||
<code>Foo</code> and <code>Bar</code> returns C++'s
|
<code>Foo</code> and <code>Bar</code> return C++'s
|
||||||
<code>std::string</code>).
|
<code>std::string</code>).
|
||||||
|
|
||||||
<p>The <code>CHECK_DOUBLE_EQ</code> macro checks the equality of two
|
<p>The <code>CHECK_DOUBLE_EQ</code> macro checks the equality of two
|
||||||
@ -383,13 +380,13 @@ analogous to <code>LOG_IF</code>, <code>LOG_EVERY_N</code>,
|
|||||||
opposed to a severity level.
|
opposed to a severity level.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
VLOG_IF(1, (size > 1024))
|
VLOG_IF(1, (size > 1024))
|
||||||
<< "I'm printed when size is more than 1024 and when you run the "
|
<< "I'm printed when size is more than 1024 and when you run the "
|
||||||
"program with --v=1 or more";
|
"program with --v=1 or more";
|
||||||
VLOG_EVERY_N(1, 10)
|
VLOG_EVERY_N(1, 10)
|
||||||
<< "I'm printed every 10th occurrence, and when you run the program "
|
<< "I'm printed every 10th occurrence, and when you run the program "
|
||||||
"with --v=1 or more. Present occurence is " << COUNTER;
|
"with --v=1 or more. Present occurence is " << COUNTER;
|
||||||
VLOG_IF_EVERY_N(1, (size > 1024), 10)
|
VLOG_IF_EVERY_N(1, (size > 1024), 10)
|
||||||
<< "I'm printed on every 10th occurence of case when size is more "
|
<< "I'm printed on every 10th occurence of case when size is more "
|
||||||
" than 1024, when you run the program with --v=1 or more. ";
|
" than 1024, when you run the program with --v=1 or more. ";
|
||||||
"Present occurence is " << COUNTER;
|
"Present occurence is " << COUNTER;
|
||||||
@ -406,7 +403,7 @@ expressions when the conditions are false. So, the following check
|
|||||||
may not sacrifice the performance of your application.
|
may not sacrifice the performance of your application.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
CHECK(obj.ok) << obj.CreatePrettyFormattedStringButVerySlow();
|
CHECK(obj.ok) << obj.CreatePrettyFormattedStringButVerySlow();
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><A NAME=failure>User-defined Failure Function</A></h3>
|
<h3><A NAME=failure>User-defined Failure Function</A></h3>
|
||||||
@ -451,13 +448,13 @@ description of the current state of errno to their output lines.
|
|||||||
E.g.
|
E.g.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
PCHECK(write(1, NULL, 2) >= 0) << "Write NULL failed";
|
PCHECK(write(1, NULL, 2) >= 0) << "Write NULL failed";
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>This check fails with the following error message.
|
<p>This check fails with the following error message.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
F0825 185142 test.cc:22] Check failed: write(1, NULL, 2) >= 0 Write NULL failed: Bad address [14]
|
F0825 185142 test.cc:22] Check failed: write(1, NULL, 2) >= 0 Write NULL failed: Bad address [14]
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3><A NAME=syslog>Syslog</A></h3>
|
<h3><A NAME=syslog>Syslog</A></h3>
|
||||||
@ -484,7 +481,7 @@ the GOOGLE_STRIP_LOG macro:
|
|||||||
#include <google/logging.h>
|
#include <google/logging.h>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>The compiler will remove the log messages whose severity are less
|
<p>The compiler will remove the log messages whose severities are less
|
||||||
than the specified integer value. Since
|
than the specified integer value. Since
|
||||||
<code>VLOG</code> logs at the severity level <code>INFO</code>
|
<code>VLOG</code> logs at the severity level <code>INFO</code>
|
||||||
(numeric value <code>0</code>),
|
(numeric value <code>0</code>),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user