Permalink
Browse files

Allow to change log level from the command line

  • Loading branch information...
1 parent 37cfefc commit 3267219e9dd5af9fc39f2672de87dacdb772bef4 @multani committed Dec 27, 2011
Showing with 10 additions and 1 deletion.
  1. +0 −1 TODO
  2. +10 −0 sonata/cli.py
View
1 TODO
@@ -55,7 +55,6 @@ clean-up
- write automated tests
- refactor code into parts that can be tested
use the logging module:
- - add verbose and debug logging modes
- log to file if not running on console
exceptions:
- add class restrictions to most "except:" clauses
View
10 sonata/cli.py
@@ -64,9 +64,19 @@ def parse(self, argv):
help=_("start app visible (requires systray)"))
parser.add_option("--profile", dest="profile", metavar="NUM",
help=_("start with profile NUM"), type=int)
+ parser.add_option("-v", "--verbose", dest="log_level",
+ action="append_const", const=-10,
+ help=_("Increase log verbosity"))
+ parser.add_option("-q", "--quiet", dest="log_level",
+ action="append_const", const=10,
+ help=_("Decrease log verbosity"))
+ parser.set_defaults(log_level=[logging.root.level])
options, self.cmds = parser.parse_args(argv[1:])
+ # Update default log level
+ logging.root.setLevel(sum(options.log_level))
+
if options.toggle:
options.start_visibility = True
if options.popup or options.fullscreen and options.start_visibility is None:

0 comments on commit 3267219

Please sign in to comment.