Log::record PHP Method

record() static public method

记录日志 并且会过滤未经设置的级别
static public record ( string $message, string $level = self::ERR, boolean $record = false ) : void
$message string 日志信息
$level string 日志级别
$record boolean 是否强制记录
return void
    static function record($message, $level = self::ERR, $record = false)
    {
        if ($record || false !== strpos("EMERG,ALERT,CRIT,ERR,WARN,NOTIC,INFO,DEBUG,SQL", $level)) {
            self::$log[] = "{$level}: {$message}\r\n";
        }
    }

Usage Example

Example #1
0
 public function team()
 {
     $this->assign('title', '团队');
     $ing_groups = D('BookGroup')->where(['status' => 0])->select();
     Log::record(print_r($ing_groups, true));
     foreach ($ing_groups as &$ing_g) {
         $books = D('Book')->where(['gid' => $ing_g['id']])->order('uid asc,id desc')->select();
         foreach ($books as &$book) {
             $user = D('User')->where(['id' => $book['uid']])->find();
             $book['uname'] = $user['name'];
         }
         $ing_g['books'] = $books;
     }
     $ed_groups = D('BookGroup')->where(['status' => 1])->select();
     foreach ($ed_groups as &$ed) {
         $books = D('Book')->where(['gid' => $ed['id']])->order('uid asc,id desc')->select();
         foreach ($books as &$book) {
             $user = D('User')->where(['id' => $book['uid']])->find();
             $book['uname'] = $user['name'];
         }
         $ed['books'] = $books;
     }
     $this->assign('ing_groups', $ing_groups);
     $this->assign('ed_groups', $ed_groups);
     $this->display('');
 }
All Usage Examples Of Log::record