Change in vdsm[master]: logging: Don't crash on non-ASCII in SimpleLogAdapter
mzamazal at redhat.com
mzamazal at redhat.com
Mon Nov 16 15:52:35 UTC 2015
Milan Zamazal has posted comments on this change.
Change subject: logging: Don't crash on non-ASCII in SimpleLogAdapter
......................................................................
Patch Set 2:
(2 comments)
https://gerrit.ovirt.org/#/c/48542/2/tests/utilsTests.py
File tests/utilsTests.py:
Line 1086: u_invalid = unichr(253) + unichr(254)
Line 1087: extra = dict(e1=u'Hello', e2='Здра́вствуйте', e3=u'שלום', e4='你好',
Line 1088: e5=invalid, e6=u_invalid)
Line 1089: log = logUtils.SimpleLogAdapter(self._log, extra)
Line 1090: log.debug("Dobrý večer")
> Again, this is invalid test. Format strings are part of the code and using
SimpleLogAdapter doesn't interpret the argument as a format string. Regardless of that, we are testing robustness here.
Line 1091: log.debug(u"Dobrý večer")
Line 1092: log.debug(invalid)
https://gerrit.ovirt.org/#/c/48542/2/vdsm/logUtils.py
File vdsm/logUtils.py:
Line 92: def process(self, msg, kwargs):
Line 93: result = ''
Line 94: for key, value in self.extra.iteritems():
Line 95: if isinstance(value, unicode):
Line 96: value = value.encode('utf-8', 'replace')
> No need to replace, all unicode code points can be encoded as utt8 (or any
'replace' is here for robustness, as this is what this patch is about.
Line 97: result += '%s=`%s`' % (key, value)
Line 98: if isinstance(msg, unicode):
Line 99: msg = msg.encode('utf-8', 'replace')
Line 100: result += '::%s' % msg
--
To view, visit https://gerrit.ovirt.org/48542
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I1930817ade1799b218913348ffa099aab2211ef7
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Milan Zamazal <mzamazal at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Milan Zamazal <mzamazal at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Vinzenz Feenstra <vfeenstr at redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>
Gerrit-HasComments: Yes
More information about the vdsm-patches
mailing list