public function __construct($logType = '') { if ($logType === '') { $logType = isset(IWeb::$app->config['logs']['type']) ? IWeb::$app->config['logs']['type'] : $this->logType; } $this->log = ILogFactory::getInstance($logType); }
/** * @brief 生成日志处理对象,包换各种介质的日志处理对象,单例模式 * @logType string $logType 日志类型 * @return object 日志对象 */ public static function getInstance($logType = '') { $className = isset(self::$logClass[$logType]) ? self::$logClass[$logType] : $logType; if (!class_exists($className)) { throw new IException("the {$className} class is not exists"); } if (!self::$log instanceof $className) { self::$log = new $className(); } return self::$log; }