Skip to content

tweaks to the Console logger #3721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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