-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Cookbook article on how to add exceptions logging in console commands #1965
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
Conversation
single: Console; Enabling logging | ||
|
||
How to enable logging in Console Commands | ||
=============================== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'line' after a heading should be as long as the heading itself, could you please change this in this document?
…clude the actual exit code
@wouterj, thanks for reviewing, I've addressed all of your comments. |
for all commands you'd need to do something more. | ||
|
||
First, you have to extend :class:`Symfony\\Bundle\\FrameworkBundle\\Console\\Application` | ||
class to override its :method:`Symfony\\Bundle\\FrameworkBundle\\Console\\Application::run` method, where exception handling should happen:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should break the line after the first word that crosses the 72th character
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
} | ||
|
||
Depending on the environment you run your command you will get the results | ||
in ``app/dev.log`` or ``app/prod.log``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the log dir is app/logs/
, not app/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks! Fixed.
The most important changes is to highlight that we're extending Symfony's code further than you *should*, which of course you're welcome to do, but we needs to be properly warned.
Hi Konstantin! I've merged this in and proofread it and made a few minor changes. I think it's a nice entry to highlight some of the more advanced parts of the command, but I did want to add a note since we're extending Symfony beyond what is normally recommended :). Thanks1 |
Thanks, Ryan! I fully agree with your note. |
Initially I though about sending PR to add console exception logging functionality to core, but after talking to @fabpot, it turned to a cookbook article on how to do that on your own.