Skip to content

Commit

Permalink
[#3340] Tweaks to console logging:
Browse files Browse the repository at this point in the history
* Tweaked language in the components section to be more useful for component people
* Added versionadded
* Tweaked description of how this feature works
  • Loading branch information
weaverryan committed Dec 26, 2013
1 parent 4834b77 commit 3945d5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
7 changes: 4 additions & 3 deletions components/console/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ method returns without actually printing.

.. tip::

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

This comment has been minimized.

Copy link
@wouterj

wouterj Dec 26, 2013

Member

You forgot the backticks


Using Command Arguments
-----------------------
Expand Down Expand Up @@ -527,4 +529,3 @@ Learn More!

.. _Packagist: https://packagist.org/packages/symfony/console
.. _ANSICON: https://github.com/adoxa/ansicon/downloads
.. _MonologBundle: https://github.com/symfony/MonologBundle
17 changes: 12 additions & 5 deletions cookbook/logging/monolog_console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
How to Configure Monolog to Display Console Messages
====================================================

It is possible to use the console to print messages for a certain :ref:`verbosity-levels`
.. versionadded:: 2.3
This feature was introduced to the MonologBundle in version 2.4, which
was first packaged with Symfony at version 2.4 (but compatible with Symfony 2.3).

This comment has been minimized.

Copy link
@xabbuh

xabbuh Dec 26, 2013

Member

I think if we include a versionadded directive for 2.3 here, we should merge the article into the 2.3 branch too. Otherwise, one might get confused when switching to the 2.3 docs.

This comment has been minimized.

Copy link
@wouterj

wouterj Dec 26, 2013

Member

I think we should just say 2.4 of the monologbundle, not talking about depedency management. We haven't done that for other versionadded blocks too

This comment has been minimized.

Copy link
@xabbuh

xabbuh Dec 26, 2013

Member

In How to Configure Monolog to Exclude 404 Errors from the Log we did it this way:

New in version 2.4: This feature was introduced to the MonologBundle in version 2.4, which was first packaged with Symfony at version 2.4.


It is possible to use the console to print messages for certain :ref:`verbosity-levels`
using the :class:`Symfony\\Component\\Console\\Output\\OutputInterface`
instance that is passed when a command gets executed.

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

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

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

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

This comment has been minimized.

Copy link
@wouterj

wouterj Dec 26, 2013

Member

You should use the backticks here too imo

There is no need to conditionally handle the verbosity settings anymore.

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

1 comment on commit 3945d5f

@tvlooy
Copy link
Contributor

@tvlooy tvlooy commented on 3945d5f Dec 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks!

Please sign in to comment.