Fix context info being missing from output when using the IO classes as PSR-3 logger, fixes #11882
parent
96f757f3a4
commit
2124f09d75
|
@ -15,6 +15,7 @@ namespace Composer\IO;
|
||||||
use Composer\Config;
|
use Composer\Config;
|
||||||
use Composer\Pcre\Preg;
|
use Composer\Pcre\Preg;
|
||||||
use Composer\Util\ProcessExecutor;
|
use Composer\Util\ProcessExecutor;
|
||||||
|
use Composer\Util\Silencer;
|
||||||
use Psr\Log\LogLevel;
|
use Psr\Log\LogLevel;
|
||||||
|
|
||||||
abstract class BaseIO implements IOInterface
|
abstract class BaseIO implements IOInterface
|
||||||
|
@ -219,6 +220,13 @@ abstract class BaseIO implements IOInterface
|
||||||
{
|
{
|
||||||
$message = (string) $message;
|
$message = (string) $message;
|
||||||
|
|
||||||
|
if ($context !== []) {
|
||||||
|
$json = Silencer::call('json_encode', $context, JSON_INVALID_UTF8_IGNORE|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||||
|
if ($json !== false) {
|
||||||
|
$message .= ' ' . $json;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (in_array($level, [LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR])) {
|
if (in_array($level, [LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR])) {
|
||||||
$this->writeError('<error>'.$message.'</error>');
|
$this->writeError('<error>'.$message.'</error>');
|
||||||
} elseif ($level === LogLevel::WARNING) {
|
} elseif ($level === LogLevel::WARNING) {
|
||||||
|
|
Loading…
Reference in New Issue