conduit r1874 - in trunk: . conduit test/python-tests
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1874 - in trunk: . conduit test/python-tests
- Date: Mon, 16 Feb 2009 07:05:26 +0000 (UTC)
Author: jstowers
Date: Mon Feb 16 07:05:26 2009
New Revision: 1874
URL: http://svn.gnome.org/viewvc/conduit?rev=1874&view=rev
Log:
2009-02-16 John Stowers <john stowers gmail com>
* conduit/Logging.py: No longer use CONDUIT_LOGLEVEL to set
the logging level, set it programatically on the root logger instead.
* conduit/Main.py: Add --debug, --quiet, and --silent command line
options, and use these to manipulate the debug level.
Fixes #548962.
* conduit/conduit.real:
* test/python-tests/common.py: Update to the new API.
Modified:
trunk/ChangeLog
trunk/conduit/Logging.py
trunk/conduit/Main.py
trunk/conduit/conduit.real
trunk/test/python-tests/common.py
Modified: trunk/conduit/Logging.py
==============================================================================
--- trunk/conduit/Logging.py (original)
+++ trunk/conduit/Logging.py Mon Feb 16 07:05:26 2009
@@ -36,11 +36,7 @@
NO_COLOR_FORMAT = "[%(name)-20s][%(levelname)-18s] %(message)s (%(filename)s:%(lineno)d)"
LOG_FILE_HANDLER = None
def __init__(self, name):
- try:
- level = getattr(logging,os.environ.get('CONDUIT_LOGLEVEL','DEBUG'))
- except AttributeError:
- level = logging.DEBUG
- logging.Logger.__init__(self, name, level)
+ logging.Logger.__init__(self, name)
#Add two handlers, a stderr one, and a file one
color_formatter = ColoredFormatter(ConduitLogger.COLOR_FORMAT)
@@ -59,4 +55,13 @@
self.addHandler(console)
return
+def enable_debugging():
+ logging.getLogger().setLevel(logging.DEBUG)
+
+def disable_debugging():
+ logging.getLogger().setLevel(logging.INFO)
+
+def disable_logging():
+ logging.getLogger().setLevel(logging.CRITICAL+1)
+
logging.setLoggerClass(ConduitLogger)
Modified: trunk/conduit/Main.py
==============================================================================
--- trunk/conduit/Main.py (original)
+++ trunk/conduit/Main.py Mon Feb 16 07:05:26 2009
@@ -3,15 +3,14 @@
import sys
import dbus, dbus.service, dbus.mainloop.glib
import gobject
+import logging
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
dbus.mainloop.glib.threads_init()
-import logging
-log = logging.getLogger("Main")
-
import conduit
import conduit.utils as Utils
+import conduit.Logging as Logging
from conduit.Module import ModuleManager
from conduit.MappingDB import MappingDB
from conduit.TypeConverter import TypeConverter
@@ -20,6 +19,8 @@
from conduit.DBus import DBusInterface
from conduit.Settings import Settings
+
+log = logging.getLogger("Main")
APPLICATION_DBUS_IFACE="org.conduit.Application"
class Application(dbus.service.Object):
@@ -80,13 +81,25 @@
metavar="mod1,mod2",
help="Do not load modules in the named files. [default: load all modules]")
parser.add_option(
- "-s", "--settings",
+ "-e", "--settings",
metavar="key=val,key=val",
help="Explicitly set internal Conduit settings (keys) to the given values for this session. [default: do not set]")
parser.add_option(
"-U", "--enable-unsupported",
action="store_true", default=False,
help="Enable loading of unfinished or unsupported dataproviders. [default: %default]")
+ parser.add_option(
+ "-d", "--debug",
+ action="store_true", default=False,
+ help="Generate more debugging information. [default: %default]")
+ parser.add_option(
+ "-q", "--quiet",
+ action="store_true", default=False,
+ help="Generate less debugging information. [default: %default]")
+ parser.add_option(
+ "-s", "--silent",
+ action="store_true", default=False,
+ help="Generate no debugging information. [default: %default]")
options, args = parser.parse_args()
whitelist = None
@@ -103,6 +116,13 @@
self.ui = options.ui
self.settingsFile = os.path.abspath(options.config_file)
+ if options.debug or not conduit.IS_INSTALLED:
+ Logging.enable_debugging()
+ if options.quiet:
+ Logging.disable_debugging()
+ if options.silent:
+ Logging.disable_logging()
+
log.info("Conduit v%s Installed: %s" % (conduit.VERSION, conduit.IS_INSTALLED))
log.info("Python: %s" % sys.version)
log.info("Platform Implementations: %s,%s,%s" % (conduit.FILE_IMPL,conduit.BROWSER_IMPL, conduit.SETTINGS_IMPL))
Modified: trunk/conduit/conduit.real
==============================================================================
--- trunk/conduit/conduit.real (original)
+++ trunk/conduit/conduit.real Mon Feb 16 07:05:26 2009
@@ -19,7 +19,6 @@
sys.path.insert(0, _dirname)
import conduit
-import conduit.Logging
import conduit.Main
app = conduit.Main.Application()
Modified: trunk/test/python-tests/common.py
==============================================================================
--- trunk/test/python-tests/common.py (original)
+++ trunk/test/python-tests/common.py Mon Feb 16 07:05:26 2009
@@ -16,7 +16,6 @@
# import main conduit modules
import conduit
-import conduit.Logging as Logging
import conduit.Settings as Settings
# set up expected paths & variables
@@ -29,6 +28,10 @@
conduit.SETTINGS_IMPL = os.environ.get("CONDUIT_SETTINGS_IMPL","GConf")
conduit.GLOBALS.settings = Settings.Settings()
+# enable all logging output
+import conduit.Logging as Logging
+Logging.enable_debugging()
+
import conduit.utils as Utils
import conduit.Vfs as Vfs
import conduit.Module as Module
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]