Browse files

feature #4658 Debug formatter tweaks (weaverryan)

This PR was merged into the 2.6 branch.


Debug formatter tweaks

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | no
| Applies to    | 2.6+
| Fixed tickets | n/a

Hi guys!

This follows with a few tweaks to #4485. The biggest was adding an image of the output early on, which helped me understand "what the heck does this debug formatter actually do?".



9e4eb5a language tweak thanks to xabbuh!
0f4fda7 Adding an example image of the debug_formatter
  • Loading branch information...
weaverryan committed Jan 16, 2015
2 parents cfad26c + 9e4eb5a commit 08e5ac990a3d8e50a834bf5d7bfc420b39f9083a
@@ -9,14 +9,23 @@ Debug Formatter Helper
The :class:`Symfony\\Component\\Console\\Helper\\DebugFormatterHelper` provides
functions to output debug information when running an external program, for
instance a process or HTTP request. It is included in the default helper set
and you can get it by calling
instance a process or HTTP request. For example, if you used it to output
the results of running ``ls -la`` on a UNIX system, it might output something
like this:
.. image:: /images/components/console/debug_formatter.png
:align: center
Using the debug_formatter
The formatter is included in the default helper set and you can get it by
calling :method:`Symfony\\Component\\Console\\Command\\Command::getHelper`::
$debugFormatter = $this->getHelper('debug_formatter');
The formatter only formats strings, which you can use to output to the console,
but also to log the information or do anything else.
The formatter accepts strings and returns a formatted string, which you then
output to the console (or even log the information or do anything else).
All methods of this helper have an identifier as the first argument. This is a
unique value for each program. This way, the helper can debug information for
@@ -39,9 +48,13 @@ display information that the program is started::
// ...
$process = new Process(...);
$output->writeln($debugFormatter->start(spl_object_hash($process), 'Some process description'));
'Some process description')
This will output:
@@ -51,7 +64,11 @@ This will output:
You can tweak the prefix using the third argument::
$output->writeln($debugFormatter->start(spl_object_hash($process), 'Some process description', 'STARTED');
'Some process description',
// will output:
// STARTED Some process description
@@ -69,7 +86,11 @@ using
$process->run(function ($type, $buffer) use ($output, $debugFormatter, $process) {
$debugFormatter->progress(spl_object_hash($process), $buffer, Process::ERR === $type)
Process::ERR === $type
// ...
Binary file not shown.

0 comments on commit 08e5ac9

Please sign in to comment.