aboutsummaryrefslogtreecommitdiff
path: root/util.py
diff options
context:
space:
mode:
authorSteve McIntyre <steve.mcintyre@linaro.org>2015-09-23 00:04:55 +0100
committerSteve McIntyre <steve.mcintyre@linaro.org>2015-09-23 00:04:55 +0100
commit26de4d917ca3ca3d549324f3e735545995e1f460 (patch)
treeb7d68038b83e7d85bb85945f33bb64846be6b7b2 /util.py
parente3fb49ae0b2168d36ff3607158365c42a7c0ed4f (diff)
Move common loglevel code into a new utility function set_logging_level()
Change-Id: I436319311192cc4ee8b29935b3acb69e0ba613e1
Diffstat (limited to 'util.py')
-rw-r--r--util.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/util.py b/util.py
index 8321ed9..e1de89d 100644
--- a/util.py
+++ b/util.py
@@ -5,6 +5,23 @@ from errors import CriticalError, InputError, ConfigError, SocketError
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