Hello Piotr Kliczewski, Dan Kenigsberg,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/59873
to review the following change.
Change subject: API: streamline and make setLogLevel correct
......................................................................
API: streamline and make setLogLevel correct
According to the schema, setLogLevel should accept
a log level string ('DEBUG', 'INFO',...). But the code
actually blindly casted the given value to int(), and this suggests
the code actually expected an integer value.
To make things a bit user friendlier and comformant to schema,
change the argument to actually be a log level in string format.
Along the way, this patch streamlines the implementation of
setLogLevel and makes it simpler.
Change-Id: Iaddbb12d13bdbaa7a02255ab209da11e42d2ea97
Backports-To: 4.0
Backports-To: 3.6
Signed-off-by: Francesco Romani <[email protected]>
Reviewed-on: https://gerrit.ovirt.org/38425
Reviewed-by: Piotr Kliczewski <[email protected]>
Reviewed-by: Dan Kenigsberg <[email protected]>
Continuous-Integration: Dan Kenigsberg <[email protected]>
---
M lib/vdsm/logUtils.py
1 file changed, 14 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/73/59873/1
diff --git a/lib/vdsm/logUtils.py b/lib/vdsm/logUtils.py
index 8a6c501..c9a75c8 100644
--- a/lib/vdsm/logUtils.py
+++ b/lib/vdsm/logUtils.py
@@ -208,8 +208,21 @@
return logging.handlers.WatchedFileHandler._open(self)
+_LEVELS = {
+ 'DEBUG': logging.DEBUG,
+ 'INFO': logging.INFO,
+ 'WARNING': logging.WARNING,
+ 'ERROR': logging.ERROR,
+ 'CRITICAL': logging.CRITICAL
+}
+
+
def set_level(level):
- logging.warning('Setting loglevel to %s', level)
+ if level not in _LEVELS:
+ raise ValueError("unknown log level: %r" % level)
+
+ log_level = _LEVELS[level]
+ logging.warning('Setting loglevel to %s (%d)', level, log_level)
handlers = logging.getLogger().handlers
[fileHandler] = [h for h in handlers if
isinstance(h, logging.FileHandler)]
--
To view, visit https://gerrit.ovirt.org/59873
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaddbb12d13bdbaa7a02255ab209da11e42d2ea97
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Francesco Romani <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Piotr Kliczewski <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]