public static function init($config = []) { $type = isset($config['type']) ? $config['type'] : 'File'; $class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\log\\driver\\') . ucwords($type); unset($config['type']); self::$driver = new $class($config); }
/** * 日志初始化 * @return void */ public static function init($config = []) { $type = isset($config['type']) ? $config['type'] : 'File'; $class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\log\\driver\\') . ucwords($type); unset($config['type']); self::$driver = new $class($config); // 记录初始化信息 APP_DEBUG && Log::record('[ LOG ] INIT ' . $type . ': ' . var_export($config, true), 'info'); }
/** * 日志初始化 * @param array $config */ 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 . ': ' . var_export($config, true), 'info'); }