diff options
author | Andrew Resch <andrewresch@gmail.com> | 2008-11-28 23:28:06 +0000 |
---|---|---|
committer | Andrew Resch <andrewresch@gmail.com> | 2008-11-28 23:28:06 +0000 |
commit | 1440d6b24702a881cab07235e93d1b2f1457aa07 (patch) | |
tree | 94c605bb43bbf8b4867394b81dd718d729f276db /deluge/log.py | |
parent | e759d61266b6bc9d0bb9eabd9e6e9cb8260df35b (diff) | |
download | deluge-1440d6b24702a881cab07235e93d1b2f1457aa07.tar.gz deluge-1440d6b24702a881cab07235e93d1b2f1457aa07.tar.bz2 deluge-1440d6b24702a881cab07235e93d1b2f1457aa07.zip |
Fix #531 set default log level to ERROR and add 2 command-line options,
"-L, --loglevel" and "-q, --quiet".
Diffstat (limited to 'deluge/log.py')
-rw-r--r-- | deluge/log.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/deluge/log.py b/deluge/log.py index 1076cf81e..2f415158c 100644 --- a/deluge/log.py +++ b/deluge/log.py @@ -29,10 +29,31 @@ import logging # Setup the logger logging.basicConfig( - level=logging.DEBUG, + level=logging.ERROR, format="[%(levelname)-8s] %(asctime)s %(module)s:%(lineno)d %(message)s", datefmt="%H:%M:%S" ) +def setLoggerLevel(level): + """ + Sets the logger level. + + :param level: str, a string representing the desired level + + """ + levels = { + "info": logging.INFO, + "warning": logging.WARNING, + "error": logging.ERROR, + "none": logging.CRITICAL, + "debug": logging.DEBUG + } + + if level not in levels: + return + + global LOG + LOG.setLevel(levels[level]) + # Get the logger LOG = logging.getLogger("deluge") |