Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow to change log level from the command line
  • Loading branch information
multani committed Dec 27, 2011
1 parent 37cfefc commit 3267219
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion TODO
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions sonata/cli.py
Expand Up @@ -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:
Expand Down

0 comments on commit 3267219

Please sign in to comment.