fix all the log statments to use %s fomatting
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Barbican |
Fix Released
|
Low
|
Arvind Tiwari |
Bug Description
This bug is concerned with the performance penalty of formatting a string. This is of special interest in debugging statements where string formatting happens inline. This is because when the formatting happens inline, it is always executed regardless of what logging level the logger is set to.
For example, in the following statements the formatting happens inline:
LOG.debug('Start on_post.
LOG.debug('Start on_post...%s' % body)
The problem is that the logger may be set to WARNING, so even though the logger will not be using the string, work was done to format it.
The fix for this is to let the logger decide whether the string should be formatted or not. To achieve this we MUST use the % formatting instead of .format() since Python loggers do not support the new formatting language.
The correct statement for the examples above should be:
LOG.debug('Start on_post...%s', body)
Note the subtle difference in passing "body" as an argument to the debug() function as opposed to using .format or % to do the formatting inline.
Changed in barbican: | |
assignee: | nobody → Arvind Tiwari (arvind-tiwari) |
description: | updated |
summary: |
- fix all the log statment to use %s fomatting + fix all the log statments to use %s fomatting |
description: | updated |
description: | updated |
Changed in barbican: | |
status: | New → Confirmed |
importance: | Undecided → Low |
milestone: | none → juno-3 |
Changed in barbican: | |
status: | Fix Committed → Fix Released |
Changed in barbican: | |
milestone: | juno-3 → 2014.2 |
Fix proposed to branch: master /review. openstack. org/115345
Review: https:/