• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • SeasLog::error()

    (PECL seaslog >=1.0.0)

    记录 error 日志

    说明

    publicstaticSeasLog::error(string $message[,array $content[,string $logger]]): bool

    记录 error 日志

    Note:

    "ERROR"- 运行时出现的错误、不必要立即进行修复、不影响整个逻辑的运行、需要记录并做检测

    参数

    $message

    日志的消息

    $content

    "消息"包含占位符,实现用 content 数组中的值替换这些占位符。例如'消息'是`log info from{NAME}`,'内容'是`array('NAME'=> neeke)`,日志信息是`log info from neeke`

    $logger

    当函数调用 SeasLog::setLogger()时,就像临时 logger 一样,在第三个参数中使用这个"logger"。如果`logger`为NULL 或"",那么 SeasLog 将使用由SeasLog::setLogger()设置的最新日志记录程序。

    返回值

    记录日志信息成功返回 TRUE,失败返回 FALSE。

    范例

    Example #1 SeasLog::error() example

    <?php
    var_dump(SeasLog::error('log message'));
    //with content
    var_dump(SeasLog::error('log message from {NAME}',array('NAME' => 'neeke')));
    //with tmp logger
    var_dump(SeasLog::error('log message from {NAME}',array('NAME' => 'neeke'),'tmp_logger'));
    var_dump(SeasLog::getBuffer());
    ?>
    

    以上例程的输出类似于:

    bool(true)
    bool(true)
    bool(true)
    array(2) {
      ["/var/log/www/default/20180707.log"]=>
      array(2) {
        [0]=>
        string(81) "2018-07-07 11:45:49 | ERROR | 73263 | 5b40376d1067c | 1530935149.68 | log message
    "
        [1]=>
        string(92) "2018-07-07 11:45:49 | ERROR | 73263 | 5b40376d1067c | 1530935149.68 | log message from neeke
    "
      }
      ["/var/log/www/tmp_logger/20180707.log"]=>
      array(1) {
        [0]=>
        string(92) "2018-07-07 11:45:49 | ERROR | 73263 | 5b40376d1067c | 1530935149.68 | log message from neeke
    "
      }
    }
    

    参见

    • seaslog.default_template
    • SeasLog::debug() 记录 debug 日志
    • SeasLog::info() Record info log information
    • SeasLog::notice() 记录 notice 日志
    • SeasLog::warning() Record warning log information
    • SeasLog::critical() 记录 critical 日志
    • SeasLog::alert() 记录 alert 日志
    • SeasLog::emergency() 记录 emergency 日志
    • SeasLog::log() 公共的日志记录函数