allow log_level to be overridden from config file
Change-Id: I855c7671c382b36d5eedecee9d09df482c8402b6
diff --git a/xos/xos/logger.py b/xos/xos/logger.py
index 3aff42b..920cf63 100644
--- a/xos/xos/logger.py
+++ b/xos/xos/logger.py
@@ -16,7 +16,7 @@
# THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS
@@ -52,6 +52,21 @@
except:
logfile = "/var/log/xos.log"
+ # allow config-file override of log level
+
+ level_str = getattr(Config(), "observer_log_level", None)
+ if level_str:
+ level_str = level_str.lower()
+
+ if level_str == "info":
+ level = logging.INFO
+ elif level_str == "debug":
+ level = logging.DEBUG
+ elif level_str == "warning":
+ level = logging.WARNING
+ elif level_str == "error":
+ level = logging.ERROR
+
if (logfile == "console"):
loggername = "console"
handler = logging.StreamHandler()