From Yaniv Bronhaim <ybron...@redhat.com>: Yaniv Bronhaim has uploaded a new change for review.
Change subject: Adding TimezoneFormatter to logUtils and use it for default log format ...................................................................... Adding TimezoneFormatter to logUtils and use it for default log format 2017-01-11 13:32:20,870+0000 INFO (jsonrpc/2) [jsonrpc.JsonRpcServer] RPC call Host.getAllVmStats succeeded in 0.00 seconds (__init__:515) 2017-01-11 13:32:22,855+0000 INFO (jsonrpc/4) [dispatcher] Run and protect: repoStats(options=None) (logUtils:66) 2017-01-11 13:32:22,855+0000 INFO (jsonrpc/4) [dispatcher] Run and protect: repoStats, Return response: {'33d5731d-665e-4a70-bb0d-84cd160a3620': {'code': 0, 'actual': True, 'version': 3, 'acquired': True, 'delay': '0.000400885', 'lastCheck': '7.3', 'valid': True}} (logUtils:69) 2017-01-11 13:32:22,865+0000 INFO (jsonrpc/4) [jsonrpc.JsonRpcServer] RPC call Host.getStats succeeded in 0.01 seconds (__init__:515) Change-Id: I139a19ea3aef1d4d3450280f269fca829fd05511 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1408190 Signed-off-by: Yaniv Bronhaim <ybron...@redhat.com> --- M automation/build-artifacts.packages.el7 M automation/build-artifacts.packages.fc25 M automation/check-merged.packages.el7 M automation/check-merged.packages.fc24 M automation/check-patch.packages.el7 M automation/check-patch.packages.fc25 M contrib/Dockerfile.centos M contrib/Dockerfile.fedora M lib/vdsm/logUtils.py M static/etc/vdsm/logger.conf.in M vdsm.spec.in 11 files changed, 34 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/20/72220/1 diff --git a/automation/build-artifacts.packages.el7 b/automation/build-artifacts.packages.el7 index 3a5d8c2..6c58335 100644 --- a/automation/build-artifacts.packages.el7 +++ b/automation/build-artifacts.packages.el7 @@ -12,6 +12,7 @@ PyYAML python-blivet python-coverage +python-dateutil python-decorator python-devel python-nose diff --git a/automation/build-artifacts.packages.fc25 b/automation/build-artifacts.packages.fc25 index 934123e..56454c8 100644 --- a/automation/build-artifacts.packages.fc25 +++ b/automation/build-artifacts.packages.fc25 @@ -13,6 +13,8 @@ python-blivet1 python-coverage python2-decorator +python2-dateutil +python3-dateutil python-devel python-nose python-inotify diff --git a/automation/check-merged.packages.el7 b/automation/check-merged.packages.el7 index 3ba5395..646dd1a 100644 --- a/automation/check-merged.packages.el7 +++ b/automation/check-merged.packages.el7 @@ -11,6 +11,7 @@ policycoreutils-python python-blivet python-coverage +python-dateutil python-decorator python-devel python-inotify diff --git a/automation/check-merged.packages.fc24 b/automation/check-merged.packages.fc24 index 9eb7be2..51c9f87 100644 --- a/automation/check-merged.packages.fc24 +++ b/automation/check-merged.packages.fc24 @@ -16,6 +16,7 @@ python-blivet python-coverage python2-decorator +python-dateutil python-devel python-inotify python-ioprocess diff --git a/automation/check-patch.packages.el7 b/automation/check-patch.packages.el7 index 2c9ea96..5e91cc6 100644 --- a/automation/check-patch.packages.el7 +++ b/automation/check-patch.packages.el7 @@ -13,6 +13,7 @@ PyYAML python-blivet python-coverage +python-dateutil python-decorator python-devel python-inotify diff --git a/automation/check-patch.packages.fc25 b/automation/check-patch.packages.fc25 index 04383fb..fb62ea1 100644 --- a/automation/check-patch.packages.fc25 +++ b/automation/check-patch.packages.fc25 @@ -16,6 +16,8 @@ python-blivet1 python-coverage python2-decorator +python2-dateutil +python3-dateutil python-devel python-inotify python-ioprocess diff --git a/contrib/Dockerfile.centos b/contrib/Dockerfile.centos index 1ffa80f..abd4a61 100644 --- a/contrib/Dockerfile.centos +++ b/contrib/Dockerfile.centos @@ -20,6 +20,7 @@ psmisc \ python-blivet \ python-cpopen \ + python-dateutil \ python-decorator \ python-devel \ python-inotify \ diff --git a/contrib/Dockerfile.fedora b/contrib/Dockerfile.fedora index 59aa609..78d537b 100644 --- a/contrib/Dockerfile.fedora +++ b/contrib/Dockerfile.fedora @@ -22,6 +22,7 @@ psmisc \ python-blivet \ python-cpopen \ + python-dateutil \ python-decorator \ python-devel \ python-inotify \ diff --git a/lib/vdsm/logUtils.py b/lib/vdsm/logUtils.py index e726d9b..ffb074c 100644 --- a/lib/vdsm/logUtils.py +++ b/lib/vdsm/logUtils.py @@ -1,5 +1,5 @@ # -# Copyright 2011 Red Hat, Inc. +# Copyright 2011-2017 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,12 +19,14 @@ # from __future__ import absolute_import +import datetime import grp import logging import logging.handlers import os import pwd import sys +from dateutil import tz from functools import wraps from inspect import ismethod @@ -208,6 +210,24 @@ return logging.handlers.WatchedFileHandler._open(self) +class TimezoneFormatter(logging.Formatter): + def converter(self, timestamp): + return datetime.datetime.fromtimestamp(timestamp, + tz.tzlocal()) + + def formatTime(self, record, datefmt=None): + ct = self.converter(record.created) + if datefmt: + s = ct.strftime(datefmt, ct) + else: + s = "%s,%03d%s" % ( + ct.strftime('%Y-%m-%d %H:%M:%S'), + record.msecs, + ct.strftime('%z') + ) + return s + + class Suppressed(object): def __init__(self, value): diff --git a/static/etc/vdsm/logger.conf.in b/static/etc/vdsm/logger.conf.in index 6241817..7be5f6b 100644 --- a/static/etc/vdsm/logger.conf.in +++ b/static/etc/vdsm/logger.conf.in @@ -80,6 +80,7 @@ [formatter_long] format: %(asctime)s %(levelname)-5s (%(threadName)s) [%(name)s] %(message)s (%(module)s:%(lineno)d) +class: vdsm.logUtils.TimezoneFormatter [formatter_sysform] format= vdsm %(name)s %(levelname)s %(message)s diff --git a/vdsm.spec.in b/vdsm.spec.in index 3659acb..0a0756d 100644 --- a/vdsm.spec.in +++ b/vdsm.spec.in @@ -62,6 +62,7 @@ BuildRequires: python BuildRequires: python-cpopen BuildRequires: python-six >= 1.9.0 +BuildRequires: python-dateutil BuildRequires: python2-devel BuildRequires: PyYAML BuildRequires: rpm-build @@ -96,6 +97,7 @@ Requires: ntp Requires: iproute >= 3.10.0 Requires: PyYAML +Requires: python-dateutil Requires: python-netaddr Requires: python-inotify Requires: python-cpopen >= 1.5 -- To view, visit https://gerrit.ovirt.org/72220 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I139a19ea3aef1d4d3450280f269fca829fd05511 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: ovirt-4.1 Gerrit-Owner: Yaniv Bronhaim <ybron...@redhat.com> _______________________________________________ vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org