Skip to content

Commit

Permalink
Fix console logger according to PSR-3
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-dev committed Jan 21, 2021
1 parent adb658b commit 86b9e48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions EventListener/ErrorListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public function onConsoleError(ConsoleErrorEvent $event)
$error = $event->getError();

if (!$inputString = $this->getInputString($event)) {
$this->logger->error('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => $error->getMessage()]);
$this->logger->critical('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => $error->getMessage()]);

return;
}

$this->logger->error('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()]);
$this->logger->critical('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()]);
}

public function onConsoleTerminate(ConsoleTerminateEvent $event)
Expand Down
4 changes: 2 additions & 2 deletions Tests/EventListener/ErrorListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testOnConsoleError()
$logger = $this->getLogger();
$logger
->expects($this->once())
->method('error')
->method('critical')
->with('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => 'test:run --foo=baz buzz', 'message' => 'An error occurred'])
;

Expand All @@ -48,7 +48,7 @@ public function testOnConsoleErrorWithNoCommandAndNoInputString()
$logger = $this->getLogger();
$logger
->expects($this->once())
->method('error')
->method('critical')
->with('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => 'An error occurred'])
;

Expand Down

0 comments on commit 86b9e48

Please sign in to comment.