mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
console: don't use colored output if there's no TTY
This prevents ANSI escape codes and style tags showing up in cron-jobs, pipes or redirects.
This commit is contained in:
parent
638d2ea7b6
commit
0c55adebe0
2 changed files with 8 additions and 2 deletions
|
@ -161,7 +161,10 @@ class ConsoleOutput {
|
||||||
public function __construct($stream = 'php://stdout') {
|
public function __construct($stream = 'php://stdout') {
|
||||||
$this->_output = fopen($stream, 'w');
|
$this->_output = fopen($stream, 'w');
|
||||||
|
|
||||||
if (DS === '\\' && !(bool)env('ANSICON')) {
|
if (
|
||||||
|
(DS === '\\' && !(bool)env('ANSICON')) ||
|
||||||
|
(function_exists('posix_isatty') && !posix_isatty($this->_output))
|
||||||
|
) {
|
||||||
$this->_outputAs = self::PLAIN;
|
$this->_outputAs = self::PLAIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,10 @@ class ConsoleLog extends BaseLog {
|
||||||
*/
|
*/
|
||||||
public function __construct($config = array()) {
|
public function __construct($config = array()) {
|
||||||
parent::__construct($config);
|
parent::__construct($config);
|
||||||
if (DS === '\\' && !(bool)env('ANSICON')) {
|
if (
|
||||||
|
(DS === '\\' && !(bool)env('ANSICON')) ||
|
||||||
|
(function_exists('posix_isatty') && !posix_isatty($this->_output))
|
||||||
|
) {
|
||||||
$outputAs = ConsoleOutput::PLAIN;
|
$outputAs = ConsoleOutput::PLAIN;
|
||||||
} else {
|
} else {
|
||||||
$outputAs = ConsoleOutput::COLOR;
|
$outputAs = ConsoleOutput::COLOR;
|
||||||
|
|
Loading…
Add table
Reference in a new issue