Update config handling for logging level, and add test

Set the default to CRITICAL only, to simplify code. Add check for the
specified logging level, and  a unit test for that.

Change-Id: I3ffa467f001dfdfb840f312bf0df8265aac58299
diff --git a/config/config.py b/config/config.py
index 3694196..02de5a8 100644
--- a/config/config.py
+++ b/config/config.py
@@ -37,6 +37,12 @@
     elif text in ('0', 'n', 'N', 'f', 'F', 'False', 'false'):
         return False
 
+def is_valid_logging_level(text):
+    valid = ('CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG')
+    if text in valid:
+        return True
+    return False
+    
 class DaemonConfigClass:
     """ Simple container for stuff to make for nicer syntax """
 
@@ -99,7 +105,7 @@
 
         # Set defaults logging details
         self.logging = LoggingConfigClass()
-        self.logging.level = None
+        self.logging.level = 'CRITICAL'
         self.logging.filename = None
 
         # Set default port number and VLAN tag
@@ -166,6 +172,9 @@
                     pass
                 except:
                     raise ConfigError('Invalid logging configuration (level)')
+                self.logging.level = self.logging.level.upper()
+                if not is_valid_logging_level(self.logging.level):
+                    raise ConfigError('Invalid logging configuration (level)')                    
 
                 try:
                     self.logging.filename = config.get(section, 'filename')