think\Log::save PHP Method

save() public static method

保存调试信息
public static save ( ) : boolean
return boolean
    public static function save()
    {
        if (!empty(self::$log)) {
            if (is_null(self::$driver)) {
                self::init(Config::get('log'));
            }
            if (!self::check(self::$config)) {
                // 检测日志写入权限
                return false;
            }
            if (empty(self::$config['level'])) {
                // 获取全部日志
                $log = self::$log;
            } else {
                // 记录允许级别
                $log = [];
                foreach (self::$config['level'] as $level) {
                    if (isset(self::$log[$level])) {
                        $log[$level] = self::$log[$level];
                    }
                }
            }
            $result = self::$driver->save($log);
            if ($result) {
                self::$log = [];
            }
            return $result;
        }
        return true;
    }

Usage Example

示例#1
0
文件: logTest.php 项目: Lofanmi/think
 public function testSave()
 {
     Log::init(['type' => 'test']);
     Log::clear();
     Log::record('test');
     Log::record([1, 2, 3]);
     $this->assertTrue(Log::save());
 }
All Usage Examples Of think\Log::save