fix all the log statments to use %s fomatting

Bug #1358500 reported by Arvind Tiwari
6
This bug affects 1 person
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...{0}'.format(body))
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
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to barbican (master)

Fix proposed to branch: master
Review: https://review.openstack.org/115345

Changed in barbican:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to barbican (master)

Reviewed: https://review.openstack.org/115345
Committed: https://git.openstack.org/cgit/openstack/barbican/commit/?id=60fd6494e89f029bb28dd62e854ea66efced4f2c
Submitter: Jenkins
Branch: master

commit 60fd6494e89f029bb28dd62e854ea66efced4f2c
Author: Arvind Tiwari <email address hidden>
Date: Tue Aug 19 09:52:45 2014 -0600

    fix all the log statments to use %s fomatting

    Closes-Bug: 1358500

    Change-Id: I010d7a7b47855cd1d5e984d5cda04ec075fe264c

Changed in barbican:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in barbican:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in barbican:
milestone: juno-3 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.