Skip to content

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

Merged
merged 6 commits into from
Dec 24, 2012

Conversation

kostiklv
Copy link
Contributor

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.

single: Console; Enabling logging

How to enable logging in Console Commands
===============================
Copy link
Member

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?

@kostiklv
Copy link
Contributor Author

@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::
Copy link
Member

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

Copy link
Contributor Author

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``.
Copy link
Member

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/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks! Fixed.

weaverryan added a commit that referenced this pull request Dec 24, 2012
weaverryan added a commit that referenced this pull request Dec 24, 2012
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.
@weaverryan weaverryan merged commit eea9f7b into symfony:2.0 Dec 24, 2012
@weaverryan
Copy link
Member

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

@kostiklv kostiklv deleted the console-logging branch December 24, 2012 17:38
@kostiklv
Copy link
Contributor Author

Thanks, Ryan! I fully agree with your note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants