Hello Dan Kenigsberg,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/59872
to review the following change.
Change subject: API: logging: move setLogLevel code into logUtils
......................................................................
API: logging: move setLogLevel code into logUtils
Move the implementation of API.setLogLevel into the
logUtils module, with minimal changes and renaming,
to make it less coupled.
The rationale for this move is that we should not have
logic in API.py besides the bare minimum.
Furthermore, setLogLevel fits nicely in the logUtils domain.
Change-Id: Iacda9f82c6e0bc22a19403b99acbfffbdb7fd2bf
Backport-To: 4.0
Backport-To: 3.6
Signed-off-by: Francesco Romani <[email protected]>
Reviewed-on: https://gerrit.ovirt.org/58990
Continuous-Integration: Jenkins CI
Reviewed-by: Dan Kenigsberg <[email protected]>
---
M lib/vdsm/logUtils.py
M vdsm/API.py
2 files changed, 10 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/59872/1
diff --git a/lib/vdsm/logUtils.py b/lib/vdsm/logUtils.py
index 5a651c9..8a6c501 100644
--- a/lib/vdsm/logUtils.py
+++ b/lib/vdsm/logUtils.py
@@ -206,3 +206,11 @@
raise RuntimeError(
"Attempt to open log with incorrect credentials")
return logging.handlers.WatchedFileHandler._open(self)
+
+
+def set_level(level):
+ logging.warning('Setting loglevel to %s', level)
+ handlers = logging.getLogger().handlers
+ [fileHandler] = [h for h in handlers if
+ isinstance(h, logging.FileHandler)]
+ fileHandler.setLevel(int(level))
diff --git a/vdsm/API.py b/vdsm/API.py
index e37569d..dd72c2b 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -21,7 +21,6 @@
# pylint: disable=R0904
import os
-import logging
from vdsm.network.errors import ConfigNetworkError
@@ -30,6 +29,7 @@
from clientIF import clientIF
from vdsm import constants
from vdsm import exception
+from vdsm import logUtils
from vdsm import hooks
from vdsm import hostdev
from vdsm import response
@@ -1374,12 +1374,7 @@
Doesn't survive a restart
"""
- logging.warning('Setting loglevel to %s', level)
- handlers = logging.getLogger().handlers
- [fileHandler] = [h for h in handlers if
- isinstance(h, logging.FileHandler)]
- fileHandler.setLevel(int(level))
-
+ logUtils.set_level(level)
return dict(status=doneCode)
# VM-related functions
--
To view, visit https://gerrit.ovirt.org/59872
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iacda9f82c6e0bc22a19403b99acbfffbdb7fd2bf
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Francesco Romani <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]