diff --git a/lib/Cake/Log/Engine/ConsoleLog.php b/lib/Cake/Log/Engine/ConsoleLog.php index 24d4fab4d8a..255be190db1 100644 --- a/lib/Cake/Log/Engine/ConsoleLog.php +++ b/lib/Cake/Log/Engine/ConsoleLog.php @@ -49,11 +49,16 @@ class ConsoleLog extends BaseLog { */ public function __construct($config = array()) { parent::__construct($config); + if (DS == '\\' && !(bool)env('ANSICON')) { + $outputAs = ConsoleOutput::PLAIN; + } else { + $outputAs = ConsoleOutput::COLOR; + } $config = Hash::merge(array( 'stream' => 'php://stderr', 'types' => null, 'scopes' => array(), - 'outputAs' => ConsoleOutput::COLOR, + 'outputAs' => $outputAs, ), $this->_config); $config = $this->config($config); if ($config['stream'] instanceof ConsoleOutput) { diff --git a/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php b/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php index 6db6bf8d147..e7868270672 100644 --- a/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php +++ b/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php @@ -116,4 +116,21 @@ public function testCombinedLogWriting() { $this->assertContains($message, $logOutput); } +/** + * test default value of stream 'outputAs' + */ + public function testDefaultOutputAs() { + TestCakeLog::config('test_console_log', array( + 'engine' => 'TestConsoleLog', + )); + if (DS == '\\' && !(bool)env('ANSICON')) { + $expected = ConsoleOutput::PLAIN; + } else { + $expected = ConsoleOutput::COLOR; + } + $stream = TestCakeLog::stream('test_console_log'); + $config = $stream->config(); + $this->assertEquals($expected, $config['outputAs']); + } + }