Logging performance improvment

Bug #1327776 reported by Avishay Balderman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Expired
Undecided
Unassigned

Bug Description

We have the log decorator that is used in diffrent modules: https://github.com/openstack/neutron/blob/master/neutron/common/log.py

We can add a check and see if the log is going to be written before we call it.

def log(method):
    """Decorator helping to log method calls."""
    def wrapper(*args, **kwargs):
        if LOG.isEnabledFor(logging.DEBUG):
            instance = args[0]
            data = {"class_name": (instance.__class__.__module__ + '.'
                                   + instance.__class__.__name__),
                    "method_name": method.__name__,
                    "args": args[1:], "kwargs": kwargs}
            LOG.debug(_('%(class_name)s method %(method_name)s'
                        ' called with arguments %(args)s %(kwargs)s'), data)
        return method(*args, **kwargs)
    return wrapper

See: https://docs.python.org/2/library/logging.html#logging.Logger.isEnabledFor

Changed in neutron:
assignee: nobody → Avishay Balderman (avishayb)
tags: added: low-hanging-fruit
Revision history for this message
Eugene Nikanorov (enikanorov) wrote :

I have feeling that log library already capable of doing such check.

That's particularly is the reason to pass string substitution parameters as parameters to a logging functions instead of constructing log message in place.

Changed in neutron:
status: New → Incomplete
Changed in neutron:
assignee: Avishay Balderman (avishayb) → nobody
PSargent (petra-sargent)
Changed in neutron:
assignee: nobody → PSargent (petra-sargent)
PSargent (petra-sargent)
Changed in neutron:
assignee: PSargent (petra-sargent) → nobody
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for neutron because there has been no activity for 60 days.]

Changed in neutron:
status: Incomplete → Expired
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.