From 23bd98c8c50c0d5865a126bc0d9eb68e56703b48 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 17 Jan 2019 17:27:49 +0100 Subject: [PATCH] Removed a small article about console logging --- _build/redirection_map | 3 ++- components/console/events.rst | 2 ++ console.rst | 11 ++++++++++- console/logging.rst | 15 --------------- 4 files changed, 14 insertions(+), 17 deletions(-) delete mode 100644 console/logging.rst diff --git a/_build/redirection_map b/_build/redirection_map index b05f315c246..8f1eb796038 100644 --- a/_build/redirection_map +++ b/_build/redirection_map @@ -117,7 +117,7 @@ /cookbook/console/commands_as_services /console/commands_as_services /cookbook/console/console_command /console /cookbook/console/index /console -/cookbook/console/logging /console/logging +/cookbook/console/logging /console /cookbook/console/request_context /console/request_context /cookbook/console/style /console/style /cookbook/console/usage /console/usage @@ -359,3 +359,4 @@ /weblink /web_link /components/weblink /components/web_link /frontend/encore/installation-no-flex /frontend/encore/installation +/console/logging /console diff --git a/components/console/events.rst b/components/console/events.rst index 52bbc1d2478..1053ce571b1 100644 --- a/components/console/events.rst +++ b/components/console/events.rst @@ -129,6 +129,8 @@ Listeners receive a $event->setError(new \LogicException('Caught exception', $exitCode, $event->getError())); }); +.. _console-events-terminate: + The ``ConsoleEvents::TERMINATE`` Event -------------------------------------- diff --git a/console.rst b/console.rst index 857c6c81431..dd2f57c985a 100644 --- a/console.rst +++ b/console.rst @@ -29,7 +29,7 @@ For example, you may want a command to create a user:: { // the name of the command (the part after "bin/console") protected static $defaultName = 'app:create-user'; - + protected function configure() { // ... @@ -314,6 +314,15 @@ console:: :class:`Symfony\\Component\\Console\\Application ` and extend the normal ``\PHPUnit\Framework\TestCase``. +Logging Command Errors +---------------------- + +Whenever an exception is thrown while running commands, Symfony adds a log +message for it including the entire failing command. In addition, Symfony +registers an :doc:`event subscriber ` to listen to the +:ref:`ConsoleEvents::TERMINATE event ` and adds a log +message whenever a command doesn't finish with the ``0`` exit status. + Learn More ---------- diff --git a/console/logging.rst b/console/logging.rst deleted file mode 100644 index 000165112b0..00000000000 --- a/console/logging.rst +++ /dev/null @@ -1,15 +0,0 @@ -.. index:: - single: Console; Enabling logging - -How to Enable Logging in Console Commands -========================================= - -In Symfony versions prior to 3.3, the Console component didn't provide any -logging capabilities out of the box and you had to implement your own exception -listener for the console. - -Starting from Symfony 3.3, the Console component provides automatic error and -exception logging. - -You can of course also access and use the :doc:`logger ` service to -log messages.