mirror of
https://github.com/wassname/sloth.git
synced 2026-07-13 17:45:34 +08:00
Enable logging
This commit is contained in:
+3
-3
@@ -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',
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user