Permalink
Browse files

fix: windows console may not have ansi color support

  • Loading branch information...
1 parent 3103323 commit 86a74e38871e8eec4c6dbb20ad6cf63462b38bea @rchavik rchavik committed Jul 2, 2012
Showing with 23 additions and 1 deletion.
  1. +6 −1 lib/Cake/Log/Engine/ConsoleLog.php
  2. +17 −0 lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.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) {
@@ -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.