Skip to content

Commit

Permalink
bug #3721 tweaks to the Console logger (xabbuh)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

tweaks to the Console logger

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.5+
| Fixed tickets |

This fixes some issue to the new Console logger introduced in #3696.

Commits
-------

610eb6b code fixes as mentioned by @dirkluijk
83adc87 fix class roles
3bbccf7 fix PSR-3 link as mentioned by @max-voloshin
9b0911b fix grammer mistake
dd16589 add logger chapter to the component's map
  • Loading branch information
weaverryan committed Mar 26, 2014
2 parents 974cb18 + 610eb6b commit cad38ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 9 additions & 9 deletions components/console/logger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ Using the Logger
introduced in Symfony 2.5.

The Console component comes with a standalone logger complying with the
`PSR-3_` standard.
Depending of the verbosity setting, log messages will be sent to the
:class:`Symfony\\Component\\Console\\Output\\OutputInterface` instance
passed as a parameter to the constructor.
`PSR-3`_ standard. Depending on the verbosity setting, log messages will
be sent to the :class:`Symfony\\Component\\Console\\Output\\OutputInterface`
instance passed as a parameter to the constructor.

The logger does not have any external dependency except ``php-fig/log``.
This is useful for console applications and commands needing a lightweight
Expand Down Expand Up @@ -63,20 +62,21 @@ You can rely on the logger to use this dependency inside a command::
{
$logger = new ConsoleLogger($output);

$myDependency = MyDependency($logger);
$myDependency = new MyDependency($logger);
$myDependency->doStuff();
}
}

The dependency will use the instance of
``Symfony\\Component\\Console\\Logger\\ConsoleLogger`` as logger.
:class:`Symfony\\Component\\Console\\Logger\\ConsoleLogger` as logger.
Log messages emitted will be displayed on the console output.

Verbosity
---------

Depending on the verbosity level that the command is run, messages may or
may not be sent to the ``Symfony\\Component\\Console\\Output\\OutputInterface`` instance.
may not be sent to the :class:`Symfony\\Component\\Console\\Output\\OutputInterface`
instance.

By default, the console logger behaves like the
:doc:`Monolog's Console Handler </cookbook/logging/monolog_console>`.
Expand All @@ -99,10 +99,10 @@ level. This behavior is configurable through the third parameter of the
constructor::

// ...
private $formatLevelMap = array(
$formatLevelMap = array(
LogLevel::CRITICAL => self::INFO,
LogLevel::DEBUG => self::ERROR,
);
$logger = new ConsoleLogger($output, array(), $formatLevelMap);

.. _PSR-3: http://www.php-fig.org/psr/psr-3/
.. _PSR-3: http://www.php-fig.org/psr/psr-3/
1 change: 1 addition & 0 deletions components/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* :doc:`/components/console/single_command_tool`
* :doc:`/components/console/changing_default_command`
* :doc:`/components/console/events`
* :doc:`/components/console/logger`
* :doc:`/components/console/helpers/index`

* **CssSelector**
Expand Down

0 comments on commit cad38ae

Please sign in to comment.