<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Get log count by level, log_path and key_word</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="seaslog.alert.html">SeasLog::alert</a></div> <div class="next" style="text-align: right; float: right;"><a href="seaslog.analyzerdetail.html">SeasLog::analyzerDetail</a></div> <div class="up"><a href="class.seaslog.html">SeasLog</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="seaslog.analyzercount" class="refentry"> <div class="refnamediv"> <h1 class="refname">SeasLog::analyzerCount</h1> <p class="verinfo">(PECL seaslog >=1.1.6)</p><p class="refpurpose"><span class="refname">SeasLog::analyzerCount</span> — <span class="dc-title">Get log count by level, log_path and key_word</span></p> </div> <div class="refsect1 description" id="refsect1-seaslog.analyzercount-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="modifier">static</span> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>SeasLog::analyzerCount</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$level</code></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$log_path</code></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$key_word</code></span> ]] )</div> <p class="para rdfs-comment"> `SeasLog` get count value of `grep -ai '{level}' | grep -aic '{key_word}'` use system pipe and return to PHP (array or int). </p> </div> <div class="refsect1 parameters" id="refsect1-seaslog.analyzercount-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <code class="parameter">level</code></dt> <dd> <p class="para"> String. The log information level. </p> </dd> <dt> <code class="parameter">log_path</code></dt> <dd> <p class="para"> String. The log information path. </p> </dd> <dt> <code class="parameter">key_word</code></dt> <dd> <p class="para"> String. The search key word for log information. </p> </dd> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-seaslog.analyzercount-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> If `level` is SEASLOG_ALL or Empty, return all levels count as `array`. If `level` is SEASLOG_INFO or the other level, return count as `int`. </p> </div> <div class="refsect1 examples" id="refsect1-seaslog.analyzercount-examples"> <h3 class="title">Examples</h3> <div class="example" id="example-4696"> <p><strong>Example #1 <span class="function"><strong>SeasLog::analyzerCount()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br />$countResult1 </span><span style="color: #007700">= </span><span style="color: #0000BB">SeasLog</span><span style="color: #007700">::</span><span style="color: #0000BB">analyzerCount</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//with `level`<br /></span><span style="color: #0000BB">$countResult2 </span><span style="color: #007700">= </span><span style="color: #0000BB">SeasLog</span><span style="color: #007700">::</span><span style="color: #0000BB">analyzerCount</span><span style="color: #007700">(</span><span style="color: #0000BB">SEASLOG_DEBUG</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//with `level` and `log_path`<br /></span><span style="color: #0000BB">$countResult3 </span><span style="color: #007700">= </span><span style="color: #0000BB">SeasLog</span><span style="color: #007700">::</span><span style="color: #0000BB">analyzerCount</span><span style="color: #007700">(</span><span style="color: #0000BB">SEASLOG_ERROR</span><span style="color: #007700">,</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'Ymd'</span><span style="color: #007700">,</span><span style="color: #0000BB">time</span><span style="color: #007700">()));<br /><br /></span><span style="color: #FF8000">//with `level` and `key_word`<br /></span><span style="color: #0000BB">$countResult4 </span><span style="color: #007700">= </span><span style="color: #0000BB">SeasLog</span><span style="color: #007700">::</span><span style="color: #0000BB">analyzerCount</span><span style="color: #007700">(</span><span style="color: #0000BB">SEASLOG_DEBUG</span><span style="color: #007700">,</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,</span><span style="color: #DD0000">'accessToken'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$countResult1</span><span style="color: #007700">,</span><span style="color: #0000BB">$countResult2</span><span style="color: #007700">,</span><span style="color: #0000BB">$countResult3</span><span style="color: #007700">,</span><span style="color: #0000BB">$countResult4</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> array(8) { ["DEBUG"]=> int(180) ["INFO"]=> int(214) ["NOTICE"]=> int(0) ["WARNING"]=> int(0) ["ERROR"]=> int(228) ["CRITICAL"]=> int(244) ["ALERT"]=> int(1) ["EMERGENCY"]=> int(0) } int(180) int(228) int(29) </pre></div> </div> </div> </div> <div class="refsect1 seealso" id="refsect1-seaslog.analyzercount-seealso"> <h3 class="title">See Also</h3> <ul class="simplelist"> <li class="member"><span class="methodname"><a href="seaslog.analyzerdetail.html" class="methodname" rel="rdfs-seeAlso">SeasLog::analyzerDetail()</a> - Get log detail by level, log_path, key_word, start, limit, order</span></li> </ul> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="seaslog.alert.html">SeasLog::alert</a></div> <div class="next" style="text-align: right; float: right;"><a href="seaslog.analyzerdetail.html">SeasLog::analyzerDetail</a></div> <div class="up"><a href="class.seaslog.html">SeasLog</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>