Merge pull request #276 from jinchun/master

添加 File Log 测试用例
This commit is contained in:
ThinkPHP
2016-02-02 21:44:56 +08:00
4 changed files with 37 additions and 6 deletions

View File

@@ -268,8 +268,6 @@ class Error
'DS' => defined('DS') ? DS : 'undefined',
'__INFO__' => defined('__INFO__') ? __INFO__ : 'undefined',
'__EXT__' => defined('__EXT__') ? __EXT__ : 'undefined',
'__INFO__' => defined('__INFO__') ? __INFO__ : 'undefined',
'__EXT__' => defined('__EXT__') ? __EXT__ : 'undefined',
];
}
}

View File

@@ -37,7 +37,7 @@ class Log
unset($config['type']);
self::$driver = new $class($config);
// 记录初始化信息
APP_DEBUG && Log::record('[ LOG ] INIT ' . $type . ':' . var_export($config, true), 'info');
APP_DEBUG && Log::record('[ LOG ] INIT ' . $type . ': ' . var_export($config, true), 'info');
}
// 通知初始化
@@ -48,7 +48,7 @@ class Log
unset($config['type']);
self::$alarm = new $class($config['alarm']);
// 记录初始化信息
APP_DEBUG && Log::record('[ CACHE ] ALARM ' . $type . ':' . var_export($config, true), 'info');
APP_DEBUG && Log::record('[ CACHE ] ALARM ' . $type . ': ' . var_export($config, true), 'info');
}
/**
@@ -111,6 +111,7 @@ class Log
/**
* 发送预警通知
* @param mixed $msg 调试信息
* @return void
*/
public static function send($msg)

View File

@@ -1,2 +0,0 @@
*
!.gitignore

View File

@@ -0,0 +1,34 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
/**
* Test File Log
*/
namespace tests\thinkphp\library\think\log\driver;
use think\Log;
class fileTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
Log::init(['type' => 'file']);
}
public function testRecord()
{
$record_msg = 'record';
Log::record($record_msg, 'notice');
$logs = Log::getLog();
$this->assertNotFalse(array_search(['type' => 'notice', 'msg' => $record_msg], $logs));
}
}