mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
fix: windows console may not have ansi color support
This commit is contained in:
parent
31033239bd
commit
86a74e3887
2 changed files with 23 additions and 1 deletions
|
@ -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 @@ class ConsoleLogTest extends CakeTestCase {
|
|||
$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']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue