think\Log::init PHP Method

init() public static method

日志初始化
public static init ( array $config = [] )
$config array
    public static function init($config = [])
    {
        $type = isset($config['type']) ? $config['type'] : 'File';
        $class = false !== strpos($type, '\\') ? $type : '\\think\\log\\driver\\' . ucwords($type);
        self::$config = $config;
        unset($config['type']);
        if (class_exists($class)) {
            self::$driver = new $class($config);
        } else {
            throw new ClassNotFoundException('class not exists:' . $class, $class);
        }
        // 记录初始化信息
        App::$debug && Log::record('[ LOG ] INIT ' . $type, 'info');
    }

Usage Example

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