LOG calls use caller-side string formatting
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
nova-dpm |
Fix Released
|
Low
|
Juergen Leopold |
Bug Description
In most modules of the DPM Nova driver, there are logging calls that format the string on the caller's side, like in this code (link: https:/
LOG.debug("HMC details %(zhmc)s %(userid)s"
% {'zhmc': zhmc, 'userid': userid})
This happens in:
nova_
nova_
nova_
The issue with this is that the formatting takes place in any case, even if logging is not turned on at all. This is not a huge performance impact, but it should be cleaned up at some point.
What should be done instead is to pass the format string (using old-style percent-formatting) and the values as separate arguments. There are two good ways to pass the values:
As positional arguments (if the values are in separate variables):
LOG.debug("HMC details %s %s", zhmc, userid)
As a dictionary (if the values are in that dictionary already):
LOG.debug("HMC details %(zhmc)s %(userid)s", mydict)
where in this example the dictionary mydict exists even if that log call would not be made, and has items with keys 'zhmc' and 'userid'.
IMO, it is less desirable (because of complexity) to build up a dictionary just for the purpose of passing it to the logging call, as shown here:
LOG.debug("HMC details %(zhmc)s %(userid)s",
description: | updated |
description: | updated |
description: | updated |
Changed in nova-dpm: | |
importance: | Undecided → Low |
Fix proposed to branch: master /review. openstack. org/456179
Review: https:/