Enable logging

This commit is contained in:
Mika Fischer
2011-06-20 16:20:38 +02:00
parent 1fc8fd0252
commit 5e5c9efd90
2 changed files with 11 additions and 4 deletions
+3 -3
View File
@@ -81,9 +81,9 @@ class BaseCommand(object):
"""
# Metadata about this command.
option_list = (
#make_option('-v', '--verbosity', action='store', dest='verbosity', default='1',
#type='choice', choices=['0', '1', '2', '3'],
#help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
make_option('-v', '--verbosity', action='store', dest='verbosity', default='2',
type='choice', choices=['0', '1', '2', '3', '4'],
help='Verbosity level; 0=critical, 1=error, 2=warning, 3=info, 4=debug'),
make_option('-c', '--config',
help='The Python path to a configuration file, e.g. "myconfig". If this isn\'t provided, sloth\'s default configuration will be used.'),
make_option('--pythonpath',
+8 -1
View File
@@ -5,7 +5,7 @@ This is the core labeltool module.
"""
import sys, os
import sys, os, logging
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from sloth.annotations.model import *
@@ -99,6 +99,13 @@ class LabelTool(QObject):
except:
pass # Ignore any option errors at this point.
# Initialize logging
loglevel = (logging.CRITICAL, logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG)[int(options.verbosity)]
logging.basicConfig(level=loglevel)
# Disable PyQt log messages
logging.getLogger("PyQt4").setLevel(logging.WARNING)
# Handle options common for all commands
# and initialize the labeltool object from
# the configuration (default config if not specified)