Skip to content
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

Support --debug flag to enable backtrace and debug logs. #332

Merged

Conversation

kyrofa
Copy link
Contributor

@kyrofa kyrofa commented Feb 22, 2016

This PR resolves LP: #1548492 by re-raising any caught exception and changing the log level to DEBUG if Snapcraft is running with the -d or --debug argument.

@@ -95,6 +95,9 @@ def main():
try:
commands.load(args['COMMAND']).main(argv=args['ARGS'])
except Exception as e:
if args['--verbose']:
Copy link
Collaborator

Choose a reason for hiding this comment

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

please let's use --debug for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I went back and forth on that-- easy peasy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Also changed log level.

@kyrofa kyrofa force-pushed the bugfix/1548492/verbose_show_backtrace branch from 695c70a to fd57ca5 Compare February 25, 2016 18:24
@kyrofa kyrofa changed the title Don't swallow exceptions if verbose. Support --debug flag to enable backtrace and debug logs. Feb 25, 2016
@kyrofa kyrofa force-pushed the bugfix/1548492/verbose_show_backtrace branch from fd57ca5 to 6cccd51 Compare February 25, 2016 18:40
args = docopt(__doc__, version=_get_version(), options_first=True)

cmd = args['COMMAND'] or 'snap'
if cmd not in _VALID_COMMANDS:
sys.exit('Command {!r} was not recognized'.format(cmd))

# Default log level is INFO unless --debug is specified
log_level = logging.INFO
if args['--debug']:
Copy link
Collaborator

Choose a reason for hiding this comment

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

--debug won't exist if it is not declared above in the docstring docopt uses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh for heaven's sake... conflict resolution fail.

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. Good catch!

@kyrofa kyrofa force-pushed the bugfix/1548492/verbose_show_backtrace branch from 6cccd51 to 7c52e52 Compare February 25, 2016 18:58
@@ -26,6 +26,7 @@
-h --help show this help message and exit
-v --version show program version and exit
-V --verbose print additional information about command execution
-d --debug print debug information while executing (backtraces, etc.)
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe (including backtraces) and leave out etc as that can mean anything

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@sergiusens
Copy link
Collaborator

One comment and we are good 👍 also rebase with master 😉

@kyrofa kyrofa force-pushed the bugfix/1548492/verbose_show_backtrace branch from 7c52e52 to 49b3d62 Compare February 27, 2016 13:13
LP: #1548492

Signed-off-by: Kyle Fazzari <kyle@canonical.com>
@kyrofa kyrofa force-pushed the bugfix/1548492/verbose_show_backtrace branch from 49b3d62 to 580c43e Compare February 27, 2016 13:18
kyrofa pushed a commit that referenced this pull request Feb 27, 2016
…race

Support --debug flag to enable backtrace and debug logs.
@kyrofa kyrofa merged commit c6e29e7 into canonical:master Feb 27, 2016
@kyrofa kyrofa deleted the bugfix/1548492/verbose_show_backtrace branch February 27, 2016 13:44
smoser pushed a commit to smoser/snapcraft that referenced this pull request Sep 14, 2016
kalikiana pushed a commit to kalikiana/snapcraft that referenced this pull request Apr 6, 2017
…how_backtrace

Support --debug flag to enable backtrace and debug logs.
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.

None yet

2 participants