Skip to content

Commit

Permalink
fix: windows console may not have ansi color support
Browse files Browse the repository at this point in the history
  • Loading branch information
rchavik committed Jul 3, 2012
1 parent 3103323 commit 86a74e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Cake/Log/Engine/ConsoleLog.php
Expand Up @@ -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) {
Expand Down
17 changes: 17 additions & 0 deletions lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php
Expand Up @@ -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']);
}

}

0 comments on commit 86a74e3

Please sign in to comment.