Php/docs/seaslog.analyzercount

来自菜鸟教程
跳转至:导航、​搜索

SeasLog::analyzerCount

(PECL seaslog >=1.1.6)

SeasLog::analyzerCountGet log count by level, log_path and key_word


说明

public static SeasLog::analyzerCount ( string $level [, string $log_path [, string $key_word ]] ) : mixed

`SeasLog` get count value of `grep -ai '{level}' | grep -aic '{key_word}'` use system pipe and return to PHP (array or int).


参数

level
String. The log information level.
log_path
String. The log information path.
key_word
String. The search key word for log information.


返回值

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`.


范例

Example #1 SeasLog::analyzerCount() example

<?php$countResult1 = SeasLog::analyzerCount();//with `level`$countResult2 = SeasLog::analyzerCount(SEASLOG_DEBUG);//with `level` and `log_path`$countResult3 = SeasLog::analyzerCount(SEASLOG_ERROR,date('Ymd',time()));//with `level` and `key_word`$countResult4 = SeasLog::analyzerCount(SEASLOG_DEBUG,NULL,'accessToken');var_dump($countResult1,$countResult2,$countResult3,$countResult4);?>

以上例程的输出类似于:


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)

参见