Module: check_mk
Branch: master
Commit: 9e5a69844c0ad569f831f43ce93e5129fb60c8f9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9e5a69844c0ad5…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Mar 28 13:17:32 2018 +0200
Moved legacy logging config conversion to load-time.
Change-Id: Ib78548304bb9f56879d28f859be6058086ad2c46
---
cmk/ec/export.py | 16 ++++++++++++++++
cmk/ec/main.py | 25 ++++++-------------------
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/cmk/ec/export.py b/cmk/ec/export.py
index 23b08f7..2960367 100644
--- a/cmk/ec/export.py
+++ b/cmk/ec/export.py
@@ -38,6 +38,7 @@ from enum import Enum
from pathlib2 import Path
from typing import Any, Dict, Iterable, List, Optional, Tuple # pylint:
disable=unused-import
+import cmk.log
import cmk.paths
import cmk.store
import cmk.ec.defaults
@@ -237,6 +238,21 @@ def load_config(settings):
"precedence": "host",
}
+ # Convert old logging configurations
+ levels = config["log_level"]
+ if isinstance(levels, int):
+ level = cmk.log.INFO if levels == 0 else cmk.log.VERBOSE
+ levels = {
+ "cmk.mkeventd": level,
+ "cmk.mkeventd.EventServer": level,
+ "cmk.mkeventd.EventStatus": level,
+ "cmk.mkeventd.StatusServer": level,
+ "cmk.mkeventd.lock": level
+ }
+ if "cmk.mkeventd.lock" not in levels:
+ levels["cmk.mkeventd.lock"] = levels["cmk.mkeventd"]
+ config["log_level"] = levels
+
return config
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index 4d2a6a9..4a0a61e 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -4931,25 +4931,12 @@ def load_configuration(settings):
# If not set by command line, set the log level by configuration
if settings.options.verbosity == 0:
- # Transform old normal/verbose config
- if g_config["log_level"] in (0, 1):
- log_level = cmk.log.INFO if g_config["log_level"] == 0 else
cmk.log.VERBOSE
-
- g_config["log_level"] = {
- "cmk.mkeventd": log_level,
- "cmk.mkeventd.EventServer": log_level,
- "cmk.mkeventd.EventStatus": log_level,
- "cmk.mkeventd.StatusServer": log_level,
- "cmk.mkeventd.lock": log_level,
- }
-
- logger.setLevel(g_config["log_level"]["cmk.mkeventd"])
-
logger.getChild("EventServer").setLevel(g_config["log_level"]["cmk.mkeventd.EventServer"])
-
logger.getChild("EventStatus").setLevel(g_config["log_level"]["cmk.mkeventd.EventStatus"])
-
logger.getChild("StatusServer").setLevel(g_config["log_level"]["cmk.mkeventd.StatusServer"])
-
- if "cmk.mkeventd.lock" in g_config["log_level"]:
-
logger.getChild("lock").setLevel(g_config["log_level"]["cmk.mkeventd.lock"])
+ levels = g_config["log_level"]
+ logger.setLevel(levels["cmk.mkeventd"])
+
logger.getChild("EventServer").setLevel(levels["cmk.mkeventd.EventServer"])
+
logger.getChild("EventStatus").setLevel(levels["cmk.mkeventd.EventStatus"])
+
logger.getChild("StatusServer").setLevel(levels["cmk.mkeventd.StatusServer"])
+
logger.getChild("lock").setLevel(levels["cmk.mkeventd.lock"])
# Configure the auto deleting indexes in the DB when mongodb is enabled
if g_config['archive_mode'] == 'mongodb':