Uploaded image for project: 'RHEL Conversions'
  1. RHEL Conversions
  2. RHELC-629

Fix lazy log evaluation for debug logging - el6

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Normal Normal
    • 0.26
    • 6.10
    • convert2rhel
    • None
    • False
    • False

      For log messages, you can do lazy evaluation of the format string to occasionally boost performance when a log message is not used. For instance:

      class Hypothetical(object):
          def str(self):
              return self.calculate_fibonacci_10000()
      log.debug("10,000th fibonacci number is: %s", Hypothetical())

      The format string will not be interpolated (and thus the 10,000th fibonacci number will not be calculated) unless we are actually going to log the debug() output.

      The code in commit b870460 broke that because it calculated its own format string and args for the message, interfering with whatever was passed in via function parameter.

              tkuratom@redhat.com Toshio Kuratomi
              tkuratom@redhat.com Toshio Kuratomi
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: