← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1327776] [NEW] Logging performance improvment

 

Public bug reported:

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

** Affects: neutron
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1327776

Title:
  Logging performance improvment

Status in OpenStack Neutron (virtual network service):
  New

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1327776/+subscriptions


Follow ups

References