diff vendor/symfony/console/Logger/ConsoleLogger.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
line wrap: on
line diff
--- a/vendor/symfony/console/Logger/ConsoleLogger.php	Mon Apr 23 09:33:26 2018 +0100
+++ b/vendor/symfony/console/Logger/ConsoleLogger.php	Mon Apr 23 09:46:53 2018 +0100
@@ -29,13 +29,7 @@
     const INFO = 'info';
     const ERROR = 'error';
 
-    /**
-     * @var OutputInterface
-     */
     private $output;
-    /**
-     * @var array
-     */
     private $verbosityLevelMap = array(
         LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
         LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
@@ -46,9 +40,6 @@
         LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
         LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
     );
-    /**
-     * @var array
-     */
     private $formatLevelMap = array(
         LogLevel::EMERGENCY => self::ERROR,
         LogLevel::ALERT => self::ERROR,
@@ -61,11 +52,6 @@
     );
     private $errored = false;
 
-    /**
-     * @param OutputInterface $output
-     * @param array           $verbosityLevelMap
-     * @param array           $formatLevelMap
-     */
     public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array())
     {
         $this->output = $output;
@@ -85,7 +71,7 @@
         $output = $this->output;
 
         // Write to the error output if necessary and available
-        if ($this->formatLevelMap[$level] === self::ERROR) {
+        if (self::ERROR === $this->formatLevelMap[$level]) {
             if ($this->output instanceof ConsoleOutputInterface) {
                 $output = $output->getErrorOutput();
             }
@@ -101,6 +87,8 @@
 
     /**
      * Returns true when any messages have been logged at error levels.
+     *
+     * @return bool
      */
     public function hasErrored()
     {
@@ -119,15 +107,23 @@
      */
     private function interpolate($message, array $context)
     {
-        // build a replacement array with braces around the context keys
-        $replace = array();
+        if (false === strpos($message, '{')) {
+            return $message;
+        }
+
+        $replacements = array();
         foreach ($context as $key => $val) {
-            if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) {
-                $replace[sprintf('{%s}', $key)] = $val;
+            if (null === $val || is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) {
+                $replacements["{{$key}}"] = $val;
+            } elseif ($val instanceof \DateTimeInterface) {
+                $replacements["{{$key}}"] = $val->format(\DateTime::RFC3339);
+            } elseif (\is_object($val)) {
+                $replacements["{{$key}}"] = '[object '.\get_class($val).']';
+            } else {
+                $replacements["{{$key}}"] = '['.\gettype($val).']';
             }
         }
 
-        // interpolate replacement values into the message and return
-        return strtr($message, $replace);
+        return strtr($message, $replacements);
     }
 }