[pkg-fso-commits] [SCM] framworkd debian packageing branch, master, updated. milestone2-110-g76700a0

Michael 'Mickey' Lauer mickey at vanille-media.de
Tue Sep 2 10:34:59 UTC 2008


The following commit has been merged in the master branch:
commit 8911eab6d722ed991676e17c2079d442636d6d94
Author: Michael 'Mickey' Lauer <mickey at vanille-media.de>
Date:   Mon Sep 1 20:46:31 2008 +0200

    enable global log_level in [frameworkd] section

diff --git a/conf/example/frameworkd.conf b/conf/example/frameworkd.conf
index dd4b105..ec6e84a 100644
--- a/conf/example/frameworkd.conf
+++ b/conf/example/frameworkd.conf
@@ -1,6 +1,8 @@
 [frameworkd]
-# indicates the configuration version, do not change
+# indicates this configuration version, do not change
 version = 1
+# the default log_level, if not specified per module
+log_level = INFO
 
 [odeviced]
 # set log level for a subsystem or for an individual module
diff --git a/framework/config.py b/framework/config.py
index a6e87db..5385808 100644
--- a/framework/config.py
+++ b/framework/config.py
@@ -25,11 +25,13 @@ import os
 import logging
 logger = logging.getLogger( "frameworkd" )
 
-logging.basicConfig(
-    level=logging.INFO,
-    format='%(name)-8s %(levelname)-8s %(message)s'
-)
-
+loggingmap = { \
+    "DEBUG": logging.DEBUG,
+    "INFO": logging.INFO,
+    "WARNING": logging.WARNING,
+    "ERROR": logging.ERROR,
+    "CRITICAL": logging.CRITICAL,
+}
 #
 # init configuration
 #
@@ -56,6 +58,9 @@ if version != NEEDS_VERSION:
     logger.warning( "[frameworkd]" )
     logger.warning( "version = %d" % NEEDS_VERSION )
 
+debug = config.getValue( "frameworkd", "log_level", "INFO" )
+logging.basicConfig( level=loggingmap.get( debug, logging.INFO ), format="%(name)-8s %(levelname)-8s %(message)s" )
+
 #
 # compute install prefix
 #
@@ -68,3 +73,6 @@ for p in searchpath:
         break
 
 logger.info( "Installprefix is %s" % installprefix )
+
+# remove unused attributes, leaving 'config' and 'debug'
+del SmartConfigParser, os, logging, logger
diff --git a/framework/controller.py b/framework/controller.py
index 689cec9..c51b7b1 100644
--- a/framework/controller.py
+++ b/framework/controller.py
@@ -9,7 +9,9 @@ GPLv2 or later
 
 __version__ = "0.9.2"
 
-from framework.config import DBUS_BUS_NAME_PREFIX
+from framework.config import DBUS_BUS_NAME_PREFIX, debug, config, loggingmap
+from optparse import OptionParser
+import subsystem
 
 import dbus, dbus.service
 from dbus.mainloop.glib import DBusGMainLoop
@@ -19,24 +21,12 @@ import os, sys, types
 import logging
 logger = logging.getLogger( "frameworkd.controller" )
 
-loggingmap = { \
-    "DEBUG": logging.DEBUG,
-    "INFO": logging.INFO,
-    "WARNING": logging.WARNING,
-    "ERROR": logging.ERROR,
-    "CRITICAL": logging.CRITICAL,
-    }
-
 try: # not present in older glib versions
     from gobject import timeout_add_seconds
 except ImportError:
     logger.error( "python-gobject >= 2.14.0 required" )
     sys.exit( -1 )
 
-from optparse import OptionParser
-from .config import config
-import subsystem
-
 #----------------------------------------------------------------------------#
 class TheOptionParser( OptionParser ):
 #----------------------------------------------------------------------------#
@@ -168,7 +158,7 @@ class Controller( object ):
     def _configureLoggers( self ):
         # configure all loggers, default being INFO
         for section in config.sections():
-            loglevel = loggingmap.get( config.getValue( section, "log_level", "INFO" ) )
+            loglevel = loggingmap.get( config.getValue( section, "log_level", debug ) )
             logger.debug( "setting logger for %s to %s" % ( section, loglevel ) )
             logging.getLogger( section ).setLevel( loglevel )
         # FIXME configure handlers

-- 
framworkd debian packageing



More information about the pkg-fso-commits mailing list