Commit f7edebb2 by Qiang Xue

Fixed test break.

parent f8b63591
......@@ -60,6 +60,10 @@ class Dispatcher extends Component
* or the configuration for creating the log target instance.
*/
public $targets = [];
/**
* @var Logger the logger. If not set, [[\Yii::getLogger()]] will be used.
*/
public $logger;
/**
* Initializes the logger by registering [[flush()]] as a shutdown function.
......@@ -74,7 +78,10 @@ class Dispatcher extends Component
}
}
Yii::getLogger()->dispatcher = $this;
if ($this->logger === null) {
$this->logger = Yii::getLogger();
}
$this->logger->dispatcher = $this;
}
/**
......@@ -83,7 +90,7 @@ class Dispatcher extends Component
*/
public function getTraceLevel()
{
return Yii::getLogger()->traceLevel;
return $this->logger->traceLevel;
}
/**
......@@ -94,7 +101,7 @@ class Dispatcher extends Component
*/
public function setTraceLevel($value)
{
Yii::getLogger()->traceLevel = $value;
$this->logger->traceLevel = $value;
}
/**
......@@ -103,7 +110,7 @@ class Dispatcher extends Component
*/
public function getFlushInterval()
{
return Yii::getLogger()->flushInterval;
return $this->logger->flushInterval;
}
/**
......@@ -116,7 +123,7 @@ class Dispatcher extends Component
*/
public function setFlushInterval($value)
{
Yii::getLogger()->flushInterval = $value;
$this->logger->flushInterval = $value;
}
/**
......
......@@ -5,6 +5,7 @@
namespace yiiunit\framework\log;
use yii\log\Dispatcher;
use yii\log\Logger;
use yii\log\Target;
use yiiunit\TestCase;
......@@ -50,7 +51,9 @@ class TargetTest extends TestCase
{
static::$messages = [];
$logger = new Logger([
$logger = new Logger;
$dispatcher = new Dispatcher([
'logger' => $logger,
'targets' => [new TestTarget(array_merge($filter, ['logVars' => []]))],
'flushInterval' => 1,
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment