驱动设计支持使用 namespace配置改变默认命名空间位置

This commit is contained in:
thinkphp
2015-12-26 17:59:07 +08:00
parent bd322b82e5
commit a746982703
7 changed files with 19 additions and 11 deletions

View File

@@ -33,7 +33,7 @@ class Log
public static function init($config = [])
{
$type = isset($config['type']) ? $config['type'] : 'File';
$class = '\\think\\log\\driver\\' . ucwords($type);
$class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\log\\driver\\') . ucwords($type);
unset($config['type']);
self::$driver = new $class($config);
}
@@ -42,7 +42,7 @@ class Log
public static function alarm($config = [])
{
$type = isset($config['type']) ? $config['type'] : 'Email';
$class = '\\think\\log\\alarm\\' . ucwords($config['type']);
$class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\log\\alarm\\') . ucwords($type);
unset($config['type']);
self::$alarm = new $class($config['alarm']);
}