Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / console / Logger / ConsoleLogger.php
index 987e96a6587e5aecaa2fcddccd2533fae843b9cd..208575cebf767fc15893f2b741f0291c1dc58dd9 100644 (file)
@@ -59,6 +59,7 @@ class ConsoleLogger extends AbstractLogger
         LogLevel::INFO => self::INFO,
         LogLevel::DEBUG => self::INFO,
     );
+    private $errored = false;
 
     /**
      * @param OutputInterface $output
@@ -81,18 +82,31 @@ class ConsoleLogger extends AbstractLogger
             throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
         }
 
+        $output = $this->output;
+
         // Write to the error output if necessary and available
-        if ($this->formatLevelMap[$level] === self::ERROR && $this->output instanceof ConsoleOutputInterface) {
-            $output = $this->output->getErrorOutput();
-        } else {
-            $output = $this->output;
+        if ($this->formatLevelMap[$level] === self::ERROR) {
+            if ($this->output instanceof ConsoleOutputInterface) {
+                $output = $output->getErrorOutput();
+            }
+            $this->errored = true;
         }
 
+        // the if condition check isn't necessary -- it's the same one that $output will do internally anyway.
+        // We only do it for efficiency here as the message formatting is relatively expensive.
         if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
-            $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)));
+            $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)), $this->verbosityLevelMap[$level]);
         }
     }
 
+    /**
+     * Returns true when any messages have been logged at error levels.
+     */
+    public function hasErrored()
+    {
+        return $this->errored;
+    }
+
     /**
      * Interpolates context values into the message placeholders.
      *