@@ -59,6 +59,7 @@ class ConsoleLogger extends AbstractLogger
59
59
LogLevel::INFO => self ::INFO ,
60
60
LogLevel::DEBUG => self ::INFO ,
61
61
);
62
+ private $ errored = false ;
62
63
63
64
/**
64
65
* @param OutputInterface $output
@@ -81,11 +82,14 @@ public function log($level, $message, array $context = array())
81
82
throw new InvalidArgumentException (sprintf ('The log level "%s" does not exist. ' , $ level ));
82
83
}
83
84
85
+ $ output = $ this ->output ;
86
+
84
87
// Write to the error output if necessary and available
85
- if ($ this ->formatLevelMap [$ level ] === self ::ERROR && $ this ->output instanceof ConsoleOutputInterface) {
86
- $ output = $ this ->output ->getErrorOutput ();
87
- } else {
88
- $ output = $ this ->output ;
88
+ if ($ this ->formatLevelMap [$ level ] === self ::ERROR ) {
89
+ if ($ this ->output instanceof ConsoleOutputInterface) {
90
+ $ output = $ output ->getErrorOutput ();
91
+ }
92
+ $ this ->errored = true ;
89
93
}
90
94
91
95
// the if condition check isn't necessary -- it's the same one that $output will do internally anyway.
@@ -95,6 +99,14 @@ public function log($level, $message, array $context = array())
95
99
}
96
100
}
97
101
102
+ /**
103
+ * Returns true when any messages have been logged at error levels.
104
+ */
105
+ public function hasErrored ()
106
+ {
107
+ return $ this ->errored ;
108
+ }
109
+
98
110
/**
99
111
* Interpolates context values into the message placeholders.
100
112
*
0 commit comments