Move common loglevel code into a new utility function set_logging_level()

Change-Id: I436319311192cc4ee8b29935b3acb69e0ba613e1
diff --git a/util.py b/util.py
index 8321ed9..e1de89d 100644
--- a/util.py
+++ b/util.py
@@ -5,6 +5,23 @@
 class VlanUtil:
     """VLANd utility functions"""
 
+    def set_logging_level(self, level):
+
+        # Set up logging and maybe go quiet...
+        if level is None:
+            level = "CRITICAL"
+
+        loglevel = logging.CRITICAL
+        if level == "ERROR":
+            loglevel = logging.ERROR
+        elif level == "WARNING":
+            loglevel = logging.WARNING
+        elif level == "INFO":
+            loglevel = logging.INFO
+        elif level == "DEBUG":
+            loglevel = logging.DEBUG
+        return loglevel
+
     def get_switch_driver(self, switch_name, config):
         logging.debug("Trying to find a driver for %s", switch_name)
         driver = config.switches[switch_name].driver