Switch to using logging() properly
Change-Id: Iabff6e9961645555c3ac7c04ccfedbd1d06930a2
diff --git a/config/config.py b/config/config.py
index ec2ee0e..c8061c1 100644
--- a/config/config.py
+++ b/config/config.py
@@ -43,6 +43,12 @@
def __repr__(self):
return "<DBConfig: server: %s, port: %s, dbname: %s, username: %s, password: %s>" % (self.server, self.port, self.dbname, self.username, self.password)
+class LoggingConfigClass:
+ """ Simple container for stuff to make for nicer syntax """
+
+ def __repr__(self):
+ return "<LoggingConfig: level: %s, filename: %s>" % (self.level, self.filename)
+
class SwitchConfigClass:
""" Simple container for stuff to make for nicer syntax """
def __repr__(self):
@@ -77,6 +83,11 @@
# No DB-specific defaults to set
self.database = DBConfigClass()
+ # Set defaults logging details
+ self.logging = LoggingConfigClass()
+ self.logging.level = None
+ self.logging.filename = None
+
# Set default port number and VLAN tag
self.vland = DaemonConfigClass()
self.vland.port = 3080
@@ -130,7 +141,19 @@
raise ConfigError('Database configuration section incomplete')
elif section == 'logging':
- pass # Fill this in later...
+ try:
+ self.logging.level = config.get(section, 'level')
+ except ConfigParser.NoOptionError:
+ pass
+ except:
+ raise ConfigError('Invalid logging configuration (level)')
+
+ try:
+ self.logging.level = config.get(section, 'filename')
+ except ConfigParser.NoOptionError:
+ pass
+ except:
+ raise ConfigError('Invalid logging configuration (filename)')
elif section == 'vland':
try: