Skip to content

Commit 3945d5f

Browse files
committed
[#3340] Tweaks to console logging:
* Tweaked language in the components section to be more useful for component people * Added versionadded * Tweaked description of how this feature works
1 parent 4834b77 commit 3945d5f

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

components/console/introduction.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,10 @@ method returns without actually printing.
230230

231231
.. tip::
232232

233-
You can use `MonologBundle`_ 2.4 to display messages on the console. This
234-
is cleaner than wrapping your output calls in conditions (see :doc:/cookbook/logging/monolog_console).
233+
The MonologBridge provides a :class:`Symfony\\Bridge\\Monolog\\Handler\\ConsoleHandler`
234+
class that allows you to display messages on the console. This is cleaner
235+
than wrapping your output calls in conditions. For an example use in
236+
the Symfony Framework, see :doc:/cookbook/logging/monolog_console.
235237

236238
Using Command Arguments
237239
-----------------------
@@ -527,4 +529,3 @@ Learn More!
527529

528530
.. _Packagist: https://packagist.org/packages/symfony/console
529531
.. _ANSICON: https://github.com/adoxa/ansicon/downloads
530-
.. _MonologBundle: https://github.com/symfony/MonologBundle

cookbook/logging/monolog_console.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
How to Configure Monolog to Display Console Messages
55
====================================================
66

7-
It is possible to use the console to print messages for a certain :ref:`verbosity-levels`
7+
.. versionadded:: 2.3
8+
This feature was introduced to the MonologBundle in version 2.4, which
9+
was first packaged with Symfony at version 2.4 (but compatible with Symfony 2.3).
10+
11+
It is possible to use the console to print messages for certain :ref:`verbosity-levels`
812
using the :class:`Symfony\\Component\\Console\\Output\\OutputInterface`
913
instance that is passed when a command gets executed.
1014

@@ -39,15 +43,18 @@ The example above could then be rewritten as::
3943

4044
protected function execute(InputInterface $input, OutputInterface $output)
4145
{
46+
// assuming the Command extends ContainerAwareCommand...
47+
$logger = $this->getContainer()->get('logger');
4248
$logger->debug('Some info');
4349

4450
$logger->notice('Some more info');
4551
}
4652

47-
These messages will get displayed on the console, timestamped, colored
48-
depending on the log level and error logs are written to the error output
49-
(php://stderr). There is no need to conditionally handle the verbosity
50-
settings anymore.
53+
Depending on the verbosity level that the command is run in and the user's
54+
configuration (see below), these messages may or may not be displayed to
55+
the console. If they are displayed, they are timestamped and colored appropriately.
56+
Additionally, error logs are written to the error output (php://stderr).
57+
There is no need to conditionally handle the verbosity settings anymore.
5158

5259
The Monolog console handler is enabled in the Monolog configuration. This is
5360
the default in Symfony Standard Edition 2.4 too.

0 commit comments

Comments
 (0)