summaryrefslogtreecommitdiffstats
path: root/deluge/ui/ui.py
diff options
context:
space:
mode:
authorPedro Algarvio <ufs@ufsoft.org>2010-12-06 11:20:22 +0000
committerPedro Algarvio <ufs@ufsoft.org>2010-12-06 11:20:22 +0000
commit3b00a7de59b2f6ed889d4c0816051af50725fa12 (patch)
treed09b5054b61cd38e03a0582a83a6d7e023893f89 /deluge/ui/ui.py
parent3d64f0d8daa0d7ee9ddefe17e55d6247c4657bcf (diff)
downloaddeluge-3b00a7de59b.tar.gz
deluge-3b00a7de59b.tar.bz2
deluge-3b00a7de59b.zip
Swhiched the old style logging, ie, a single logger for all logging output to several loggers. This brings the ability to tweak the logging levels for each of the loggers, ie, we can have the "deluge" logger be at the ERROR level while having "deluge.core" at the DEBUG level, meaning we will only see log message for all of the deluge loggers above the ERROR level while still having all messages above the DEBUG level for the "deluge.core" logger and it's children. This kind of tweak can be achieved by adding a file named "logging.conf" to deluge's config dir and this is explained on the `deluge.log.tweak_logging_levels` function.
Passing `-r` to the cli's while also passing `-l` will make the logfile rotate when reaching 5Mb in size. Three backups will be kept at all times. All deluge's code is now using this new style logging along with the git hosted plugins. For other plugins not hosted by deluge, which still imports `LOG` as the logger, a deprecation warning will be shown explaining the required changes needed to use the new style logging. New plugins created by the `create_plugin` script will use the new logging facilities.
Diffstat (limited to 'deluge/ui/ui.py')
-rw-r--r--deluge/ui/ui.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/deluge/ui/ui.py b/deluge/ui/ui.py
index b210e2d1d..06fe76c4e 100644
--- a/deluge/ui/ui.py
+++ b/deluge/ui/ui.py
@@ -33,6 +33,7 @@
#
#
+import logging
from optparse import OptionParser, OptionGroup
import deluge.common
import deluge.configmanager
@@ -65,6 +66,8 @@ class _UI(object):
help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str")
group.add_option("-q", "--quiet", dest="quiet",
help="Sets the log level to 'none', this is the same as `-L none`", action="store_true", default=False)
+ group.add_option("-r", "--rotate-logs",
+ help="Rotate logfiles.", action="store_true", default=False)
self.__parser.add_option_group(group)
@property
@@ -89,9 +92,17 @@ class _UI(object):
if self.__options.quiet:
self.__options.loglevel = "none"
+ logfile_mode = 'w'
+ if self.__options.rotate_logs:
+ logfile_mode = 'a'
+
+ # Setup the logger
# Setup the logger
- deluge.log.setupLogger(level=self.__options.loglevel, filename=self.__options.logfile)
- log = deluge.log.LOG
+ deluge.log.setupLogger(level=self.__options.loglevel,
+ filename=self.__options.logfile,
+ filemode=logfile_mode)
+
+ log = logging.getLogger(__name__)
if self.__options.config:
if not deluge.configmanager.set_config_dir(self.__options.config):
@@ -105,7 +116,8 @@ class _UI(object):
class UI:
def __init__(self, options, args, ui_args):
- from deluge.log import LOG as log
+ import logging
+ log = logging.getLogger(__name__)
log.debug("UI init..")
# Set the config directory