symfony/symfony — pull request #8033 by Tobion (2013-05-14 09:18:54+00:00)
Title: [RFC][WIP][FrameworkBundle/Console] add possibility to print log messages to command output

This PR adds the possibility to print log messages to command output depending on verbosity settings. For example: You have a command that uses a service which also logs some messages. Now you can easily also see the logged messages in the console.
You can configure the the level of information with the verbosity settings. So when this feature is enabled
- `app/console mycommand` will show all `WARNING` and higher logs
- `app/console mycommand -v` will show all `NOTICE` and higher logs
- `app/console mycommand -vv` will show all `INFO` and higher logs
- `app/console mycommand -vvv` will show all `DEBUG` and higher logs

I think it's a nice feature because the verbosity settings and logs are highly related and thus integration should be available.

I made the `$loggerService` configurable so that a user can use a different logger service (e.g. one that uses a custom channel).

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR | [todo]

Todo:
- [ ] find a good name for the method
- [ ] add a method to also disable this behavior
- [ ] use a custom handler that uses ConsoleOutput::getErrorOutput ('php://stderr') for errors?
- [ ] probably also use a custom formatter that colors the output depending on log level
- [ ] make it possible to enable this feature by default via config