However, it is possible to customize the destination by installing a callback
using the <codeclass="language-cpp highlight"><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">InstallFailureWriter</span><spanclass="p">()</span></code> function. The function expects
a pointer to a function with the following signature:</p>
<p>By default, glog tries to dump the stacktrace and calls <codeclass="language-cpp highlight"><spanclass="n">std</span><spanclass="o">::</span><spanclass="n">abort</span></code>. The
<p>By default, glog tries to dump the stacktrace and calls <codeclass="language-cpp highlight"><spanclass="n">std</span><spanclass="o">::</span><spanclass="n">abort</span></code>. The
stacktrace is generated only when running the application on a system supported
stacktrace is generated only when running the application on a system
by glog. Currently, glog supports x86, x86_64, PowerPC architectures,
supported<supid="fnref:1"><aclass="footnote-ref"href="#fn:1">1</a></sup> by glog.</p>
<code>libunwind</code>, and the Debug Help Library (<code>dbghelp</code>) on Windows for extracting
<divclass="footnote">
the stack trace.</p>
<hr/>
<ol>
<liid="fn:1">
<p>To extract the stack trace, glog currently supports the following targets:</p>
<ul>
<li>x86, x86_64,</li>
<li>PowerPC architectures,</li>
<li><code>libunwind</code>,</li>
<li>and the Debug Help Library (<code>dbghelp</code>) on Windows.</li>
</ul>
<p><aclass="footnote-backref"href="#fnref:1"title="Jump back to footnote 1 in the text">↩</a></p>
<p>Show all <codeclass="language-cpp highlight"><spanclass="n">VLOG</span><spanclass="p">(</span><spanclass="n">m</span><spanclass="p">)</span></code> messages for <code>m</code> less or equal the value of this
flag. Overridable by <codeclass="language-bash highlight">--vmodule</code>. Refer to <ahref="#verbose-logging">verbose
</span><spanid="__span-5-2"><aid="__codelineno-5-2"name="__codelineno-5-2"href="#__codelineno-5-2"></a><spanclass="c1">// Most flags work immediately after updating values.</span>
</span><spanid="__span-5-6"><aid="__codelineno-5-6"name="__codelineno-5-6"href="#__codelineno-5-6"></a><spanclass="c1">// This won’t change the log destination. If you want to set this</span>
</span><spanid="__span-5-7"><aid="__codelineno-5-7"name="__codelineno-5-7"href="#__codelineno-5-7"></a><spanclass="c1">// value, you should do this before google::InitGoogleLogging .</span>
</span><spanid="__span-5-9"><aid="__codelineno-5-9"name="__codelineno-5-9"href="#__codelineno-5-9"></a><spanclass="n">LOG</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"the same file"</span><spanclass="p">;</span>
<p>Sometimes, you may only want to log a message under certain conditions.
<p>Sometimes, you may only want to log a message under certain conditions.
You can use the following macros to perform conditional logging:</p>
You can use the following macros to perform conditional logging:</p>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-6-1"><aid="__codelineno-6-1"name="__codelineno-6-1"href="#__codelineno-6-1"></a><spanclass="n">LOG_IF</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="n">num_cookies</span><spanclass="w"></span><spanclass="o">></span><spanclass="w"></span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got lots of cookies"</span><spanclass="p">;</span>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-3-1"><aid="__codelineno-3-1"name="__codelineno-3-1"href="#__codelineno-3-1"></a><spanclass="n">LOG_IF</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="n">num_cookies</span><spanclass="w"></span><spanclass="o">></span><spanclass="w"></span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got lots of cookies"</span><spanclass="p">;</span>
</span></code></pre></div>
</span></code></pre></div>
<p>The "Got lots of cookies" message is logged only when the variable
<p>The "Got lots of cookies" message is logged only when the variable
<code>num_cookies</code> exceeds 10. If a line of code is executed many times, it may be
<code>num_cookies</code> exceeds 10. If a line of code is executed many times, it may be
useful to only log a message at certain intervals. This kind of logging is most
useful to only log a message at certain intervals. This kind of logging is most
useful for informational messages.</p>
useful for informational messages.</p>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-7-1"><aid="__codelineno-7-1"name="__codelineno-7-1"href="#__codelineno-7-1"></a><spanclass="n">LOG_EVERY_N</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got the "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"th cookie"</span><spanclass="p">;</span>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-4-1"><aid="__codelineno-4-1"name="__codelineno-4-1"href="#__codelineno-4-1"></a><spanclass="n">LOG_EVERY_N</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got the "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"th cookie"</span><spanclass="p">;</span>
</span></code></pre></div>
</span></code></pre></div>
<p>The above line outputs a log messages on the 1st, 11th, 21st, ... times
<p>The above line outputs a log messages on the 1st, 11th, 21st, ... times
it is executed.</p>
it is executed.</p>
@ -1221,20 +1090,20 @@ it is executed.</p>
</div>
</div>
<p>You can combine conditional and occasional logging with the following
<p>You can combine conditional and occasional logging with the following
macro.</p>
macro.</p>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-8-1"><aid="__codelineno-8-1"name="__codelineno-8-1"href="#__codelineno-8-1"></a><spanclass="n">LOG_IF_EVERY_N</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="p">(</span><spanclass="n">size</span><spanclass="w"></span><spanclass="o">></span><spanclass="w"></span><spanclass="mi">1024</span><spanclass="p">),</span><spanclass="w"></span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got the "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-5-1"><aid="__codelineno-5-1"name="__codelineno-5-1"href="#__codelineno-5-1"></a><spanclass="n">LOG_IF_EVERY_N</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="p">(</span><spanclass="n">size</span><spanclass="w"></span><spanclass="o">></span><spanclass="w"></span><spanclass="mi">1024</span><spanclass="p">),</span><spanclass="w"></span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got the "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span>
</span><spanid="__span-8-2"><aid="__codelineno-8-2"name="__codelineno-8-2"href="#__codelineno-8-2"></a><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"th big cookie"</span><spanclass="p">;</span>
</span><spanid="__span-5-2"><aid="__codelineno-5-2"name="__codelineno-5-2"href="#__codelineno-5-2"></a><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"th big cookie"</span><spanclass="p">;</span>
</span></code></pre></div>
</span></code></pre></div>
<p>Instead of outputting a message every nth time, you can also limit the
<p>Instead of outputting a message every nth time, you can also limit the
output to the first n occurrences:</p>
output to the first n occurrences:</p>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-9-1"><aid="__codelineno-9-1"name="__codelineno-9-1"href="#__codelineno-9-1"></a><spanclass="n">LOG_FIRST_N</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mi">20</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got the "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"th cookie"</span><spanclass="p">;</span>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-6-1"><aid="__codelineno-6-1"name="__codelineno-6-1"href="#__codelineno-6-1"></a><spanclass="n">LOG_FIRST_N</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mi">20</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got the "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"th cookie"</span><spanclass="p">;</span>
</span></code></pre></div>
</span></code></pre></div>
<p>Outputs log messages for the first 20 times it is executed. The <codeclass="language-cpp highlight"><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span></code> identifier indicates which repetition is happening.</p>
<p>Outputs log messages for the first 20 times it is executed. The <codeclass="language-cpp highlight"><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span></code> identifier indicates which repetition is happening.</p>
<p>Other times, it is desired to only log a message periodically based on a
<p>Other times, it is desired to only log a message periodically based on a
time. For instance, to log a message every 10ms:</p>
time. For instance, to log a message every 10ms:</p>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-10-1"><aid="__codelineno-10-1"name="__codelineno-10-1"href="#__codelineno-10-1"></a><spanclass="n">LOG_EVERY_T</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mf">0.01</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got a cookie"</span><spanclass="p">;</span>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-7-1"><aid="__codelineno-7-1"name="__codelineno-7-1"href="#__codelineno-7-1"></a><spanclass="n">LOG_EVERY_T</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mf">0.01</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got a cookie"</span><spanclass="p">;</span>
</span></code></pre></div>
</span></code></pre></div>
<p>Or every 2.35s:</p>
<p>Or every 2.35s:</p>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-11-1"><aid="__codelineno-11-1"name="__codelineno-11-1"href="#__codelineno-11-1"></a><spanclass="n">LOG_EVERY_T</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mf">2.35</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got a cookie"</span><spanclass="p">;</span>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-8-1"><aid="__codelineno-8-1"name="__codelineno-8-1"href="#__codelineno-8-1"></a><spanclass="n">LOG_EVERY_T</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mf">2.35</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got a cookie"</span><spanclass="p">;</span>
<p>When you are chasing difficult bugs, thorough log messages are very
<p>When you are chasing difficult bugs, thorough log messages are very
@ -1242,8 +1111,8 @@ useful. However, you may want to ignore too verbose messages in usual
development. For such verbose logging, glog provides the <code>VLOG</code> macro, which
development. For such verbose logging, glog provides the <code>VLOG</code> macro, which
allows you to define your own numeric logging levels.</p>
allows you to define your own numeric logging levels.</p>
<p>The <codeclass="language-bash highlight">--v</code> command line option controls which verbose messages are logged:</p>
<p>The <codeclass="language-bash highlight">--v</code> command line option controls which verbose messages are logged:</p>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-12-1"><aid="__codelineno-12-1"name="__codelineno-12-1"href="#__codelineno-12-1"></a><spanclass="n">VLOG</span><spanclass="p">(</span><spanclass="mi">1</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"I’m printed when you run the program with --v=1 or higher"</span><spanclass="p">;</span>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-9-1"><aid="__codelineno-9-1"name="__codelineno-9-1"href="#__codelineno-9-1"></a><spanclass="n">VLOG</span><spanclass="p">(</span><spanclass="mi">1</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"I’m printed when you run the program with --v=1 or higher"</span><spanclass="p">;</span>
</span><spanid="__span-12-2"><aid="__codelineno-12-2"name="__codelineno-12-2"href="#__codelineno-12-2"></a><spanclass="n">VLOG</span><spanclass="p">(</span><spanclass="mi">2</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"I’m printed when you run the program with --v=2 or higher"</span><spanclass="p">;</span>
</span><spanid="__span-9-2"><aid="__codelineno-9-2"name="__codelineno-9-2"href="#__codelineno-9-2"></a><spanclass="n">VLOG</span><spanclass="p">(</span><spanclass="mi">2</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"I’m printed when you run the program with --v=2 or higher"</span><spanclass="p">;</span>
</span></code></pre></div>
</span></code></pre></div>
<p>With <code>VLOG</code>, the lower the verbose level, the more likely messages are to be
<p>With <code>VLOG</code>, the lower the verbose level, the more likely messages are to be
logged. For example, if <codeclass="language-bash highlight">--v<spanclass="o">==</span><spanclass="m">1</span></code>, <codeclass="language-cpp highlight"><spanclass="n">VLOG</span><spanclass="p">(</span><spanclass="mi">1</span><spanclass="p">)</span></code> will log, but <codeclass="language-cpp highlight"><spanclass="n">VLOG</span><spanclass="p">(</span><spanclass="mi">2</span><spanclass="p">)</span></code> will not log.</p>
logged. For example, if <codeclass="language-bash highlight">--v<spanclass="o">==</span><spanclass="m">1</span></code>, <codeclass="language-cpp highlight"><spanclass="n">VLOG</span><spanclass="p">(</span><spanclass="mi">1</span><spanclass="p">)</span></code> will log, but <codeclass="language-cpp highlight"><spanclass="n">VLOG</span><spanclass="p">(</span><spanclass="mi">2</span><spanclass="p">)</span></code> will not log.</p>
@ -1259,7 +1128,7 @@ common values for them are small positive integers. For example, if you write
useful since we may not want verbose logs by default in most cases. The <code>VLOG</code>
useful since we may not want verbose logs by default in most cases. The <code>VLOG</code>
macros always log at the <code>INFO</code> log level (when they log at all).</p>
macros always log at the <code>INFO</code> log level (when they log at all).</p>
<p>Verbose logging can be controlled from the command line on a per-module basis:</p>
<p>Verbose logging can be controlled from the command line on a per-module basis:</p>
<p>Specifying these options will specifically:</p>
<p>Specifying these options will specifically:</p>
<ol>
<ol>
@ -1270,28 +1139,31 @@ macros always log at the <code>INFO</code> log level (when they log at all).</p>
</ol>
</ol>
<p>The wildcarding functionality 3. supports both <code>*</code> (matches 0 or more
<p>The wildcarding functionality 3. supports both <code>*</code> (matches 0 or more
characters) and <code>?</code> (matches any single character) wildcards. Please also refer
characters) and <code>?</code> (matches any single character) wildcards. Please also refer
to <ahref="#adjusting-output">command line flags</a> for more information.</p>
to <ahref="../flags/">command line flags</a> for more information.</p>
<p>There's also <codeclass="language-cpp highlight"><spanclass="n">VLOG_IS_ON</span><spanclass="p">(</span><spanclass="n">n</span><spanclass="p">)</span></code> "verbose level" condition macro. This macro
<p>There's also <codeclass="language-cpp highlight"><spanclass="n">VLOG_IS_ON</span><spanclass="p">(</span><spanclass="n">n</span><spanclass="p">)</span></code> "verbose level" condition macro. This macro
returns <codeclass="language-cpp highlight"><spanclass="nb">true</span></code> when the <code>--v</code> is equal to or greater than <code>n</code>. The macro can be
returns <codeclass="language-cpp highlight"><spanclass="nb">true</span></code> when the <code>--v</code> is equal to or greater than <code>n</code>. The macro can be
</span><spanid="__span-14-2"><aid="__codelineno-14-2"name="__codelineno-14-2"href="#__codelineno-14-2"></a><spanclass="w"></span><spanclass="c1">// do some logging preparation and logging</span>
</span><spanid="__span-14-3"><aid="__codelineno-14-3"name="__codelineno-14-3"href="#__codelineno-14-3"></a><spanclass="w"></span><spanclass="c1">// that can’t be accomplished with just VLOG(2) << ...;</span>
<li>Here we can perform some logging preparation and logging that can’t be
accomplished with just <codeclass="language-cpp highlight"><spanclass="n">VLOG</span><spanclass="p">(</span><spanclass="mi">2</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"message ..."</span><spanclass="p">;</span></code></li>
</ol>
<p>Verbose level condition macros <code>VLOG_IF</code>, <code>VLOG_EVERY_N</code> and <code>VLOG_IF_EVERY_N</code>
<p>Verbose level condition macros <code>VLOG_IF</code>, <code>VLOG_EVERY_N</code> and <code>VLOG_IF_EVERY_N</code>
behave analogous to <code>LOG_IF</code>, <code>LOG_EVERY_N</code>, <code>LOG_IF_EVERY_N</code>, but accept a
behave analogous to <code>LOG_IF</code>, <code>LOG_EVERY_N</code>, <code>LOG_IF_EVERY_N</code>, but accept a
numeric verbosity level as opposed to a severity level.</p>
numeric verbosity level as opposed to a severity level.</p>
</span><spanid="__span-15-2"><aid="__codelineno-15-2"name="__codelineno-15-2"href="#__codelineno-15-2"></a><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"I’m printed when size is more than 1024 and when you run the "</span>
</span><spanid="__span-12-2"><aid="__codelineno-12-2"name="__codelineno-12-2"href="#__codelineno-12-2"></a><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"I’m printed when size is more than 1024 and when you run the "</span>
</span><spanid="__span-15-3"><aid="__codelineno-15-3"name="__codelineno-15-3"href="#__codelineno-15-3"></a><spanclass="w"></span><spanclass="s">"program with --v=1 or more"</span><spanclass="p">;</span>
</span><spanid="__span-12-3"><aid="__codelineno-12-3"name="__codelineno-12-3"href="#__codelineno-12-3"></a><spanclass="w"></span><spanclass="s">"program with --v=1 or more"</span><spanclass="p">;</span>
</span><spanid="__span-15-5"><aid="__codelineno-15-5"name="__codelineno-15-5"href="#__codelineno-15-5"></a><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"I’m printed every 10th occurrence, and when you run the program "</span>
</span><spanid="__span-12-5"><aid="__codelineno-12-5"name="__codelineno-12-5"href="#__codelineno-12-5"></a><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"I’m printed every 10th occurrence, and when you run the program "</span>
</span><spanid="__span-15-6"><aid="__codelineno-15-6"name="__codelineno-15-6"href="#__codelineno-15-6"></a><spanclass="w"></span><spanclass="s">"with --v=1 or more. Present occurrence is "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span><spanclass="p">;</span>
</span><spanid="__span-12-6"><aid="__codelineno-12-6"name="__codelineno-12-6"href="#__codelineno-12-6"></a><spanclass="w"></span><spanclass="s">"with --v=1 or more. Present occurrence is "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span><spanclass="p">;</span>
</span><spanid="__span-15-8"><aid="__codelineno-15-8"name="__codelineno-15-8"href="#__codelineno-15-8"></a><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"I’m printed on every 10th occurrence of case when size is more "</span>
</span><spanid="__span-12-8"><aid="__codelineno-12-8"name="__codelineno-12-8"href="#__codelineno-12-8"></a><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"I’m printed on every 10th occurrence of case when size is more "</span>
</span><spanid="__span-15-9"><aid="__codelineno-15-9"name="__codelineno-15-9"href="#__codelineno-15-9"></a><spanclass="w"></span><spanclass="s">" than 1024, when you run the program with --v=1 or more. "</span><spanclass="p">;</span>
</span><spanid="__span-12-9"><aid="__codelineno-12-9"name="__codelineno-12-9"href="#__codelineno-12-9"></a><spanclass="w"></span><spanclass="s">" than 1024, when you run the program with --v=1 or more. "</span><spanclass="p">;</span>
</span><spanid="__span-15-10"><aid="__codelineno-15-10"name="__codelineno-15-10"href="#__codelineno-15-10"></a><spanclass="w"></span><spanclass="s">"Present occurrence is "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span><spanclass="p">;</span>
</span><spanid="__span-12-10"><aid="__codelineno-12-10"name="__codelineno-12-10"href="#__codelineno-12-10"></a><spanclass="w"></span><spanclass="s">"Present occurrence is "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span><spanclass="p">;</span>
</span></code></pre></div>
</span></code></pre></div>
<divclass="admonition info">
<divclass="admonition info">
<pclass="admonition-title">Performance</p>
<pclass="admonition-title">Performance</p>
@ -1299,18 +1171,18 @@ numeric verbosity level as opposed to a severity level.</p>
<code>VLOG</code>, etc.) are carefully implemented and don't execute the right hand
<code>VLOG</code>, etc.) are carefully implemented and don't execute the right hand
side expressions when the conditions are false. So, the following check may
side expressions when the conditions are false. So, the following check may
not sacrifice the performance of your application.</p>
not sacrifice the performance of your application.</p>
</span><spanid="__span-17-2"><aid="__codelineno-17-2"name="__codelineno-17-2"href="#__codelineno-17-2"></a><spanclass="n">DLOG_IF</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="n">num_cookies</span><spanclass="w"></span><spanclass="o">></span><spanclass="w"></span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got lots of cookies"</span><spanclass="p">;</span>
</span><spanid="__span-14-2"><aid="__codelineno-14-2"name="__codelineno-14-2"href="#__codelineno-14-2"></a><spanclass="n">DLOG_IF</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="n">num_cookies</span><spanclass="w"></span><spanclass="o">></span><spanclass="w"></span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got lots of cookies"</span><spanclass="p">;</span>
</span><spanid="__span-17-3"><aid="__codelineno-17-3"name="__codelineno-17-3"href="#__codelineno-17-3"></a><spanclass="n">DLOG_EVERY_N</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got the "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"th cookie"</span><spanclass="p">;</span>
</span><spanid="__span-14-3"><aid="__codelineno-14-3"name="__codelineno-14-3"href="#__codelineno-14-3"></a><spanclass="n">DLOG_EVERY_N</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got the "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"th cookie"</span><spanclass="p">;</span>
</span><spanid="__span-17-4"><aid="__codelineno-17-4"name="__codelineno-17-4"href="#__codelineno-17-4"></a><spanclass="n">DLOG_FIRST_N</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got the "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"th cookie"</span><spanclass="p">;</span>
</span><spanid="__span-14-4"><aid="__codelineno-14-4"name="__codelineno-14-4"href="#__codelineno-14-4"></a><spanclass="n">DLOG_FIRST_N</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got the "</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="n">google</span><spanclass="o">::</span><spanclass="n">COUNTER</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"th cookie"</span><spanclass="p">;</span>
</span><spanid="__span-17-5"><aid="__codelineno-17-5"name="__codelineno-17-5"href="#__codelineno-17-5"></a><spanclass="n">DLOG_EVERY_T</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mf">0.01</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got a cookie"</span><spanclass="p">;</span>
</span><spanid="__span-14-5"><aid="__codelineno-14-5"name="__codelineno-14-5"href="#__codelineno-14-5"></a><spanclass="n">DLOG_EVERY_T</span><spanclass="p">(</span><spanclass="n">INFO</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mf">0.01</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">"Got a cookie"</span><spanclass="p">;</span>
<p>You may append to the error message like so:</p>
<p>You may append to the error message like so:</p>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-19-1"><aid="__codelineno-19-1"name="__codelineno-19-1"href="#__codelineno-19-1"></a><spanclass="n">CHECK_NE</span><spanclass="p">(</span><spanclass="mi">1</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mi">2</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">": The world must be ending!"</span><spanclass="p">;</span>
<divclass="language-cpp highlight"><pre><span></span><code><spanid="__span-16-1"><aid="__codelineno-16-1"name="__codelineno-16-1"href="#__codelineno-16-1"></a><spanclass="n">CHECK_NE</span><spanclass="p">(</span><spanclass="mi">1</span><spanclass="p">,</span><spanclass="w"></span><spanclass="mi">2</span><spanclass="p">)</span><spanclass="w"></span><spanclass="o"><<</span><spanclass="w"></span><spanclass="s">": The world must be ending!"</span><spanclass="p">;</span>
</span></code></pre></div>
</span></code></pre></div>
<p>We are very careful to ensure that each argument is evaluated exactly
<p>We are very careful to ensure that each argument is evaluated exactly
once, and that anything which is legal to pass as a function argument is legal
once, and that anything which is legal to pass as a function argument is legal
here. In particular, the arguments may be temporary expressions which will end
here. In particular, the arguments may be temporary expressions which will end
up being destroyed at the end of the apparent statement, for example:</p>
up being destroyed at the end of the apparent statement, for example:</p>
<p>The compiler reports an error if one of the arguments is a pointer and the other
<p>The compiler reports an error if one of the arguments is a pointer and the other
is <codeclass="language-cpp highlight"><spanclass="k">nullptr</span></code>. To work around this, simply <codeclass="language-cpp highlight"><spanclass="k">static_cast</span></code><codeclass="language-cpp highlight"><spanclass="k">nullptr</span></code> to the type of the desired pointer.</p>
is <codeclass="language-cpp highlight"><spanclass="k">nullptr</span></code>. To work around this, simply <codeclass="language-cpp highlight"><spanclass="k">static_cast</span></code><codeclass="language-cpp highlight"><spanclass="k">nullptr</span></code> to the type of the desired pointer.</p>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.