switch logging to proper usage 47/24947/3
authorRoss Brattain <ross.b.brattain@intel.com>
Fri, 25 Nov 2016 22:21:37 +0000 (14:21 -0800)
committerRoss Brattain <ross.b.brattain@intel.com>
Thu, 1 Dec 2016 00:48:34 +0000 (16:48 -0800)
commit4630e877d70ba453ac0d88e226a66a6f1efc7608
tree644b8c9409c048d9cd04eacb1c19c59000612f61
parent462f25c8e950110a1624909d4f79ef4219005ba2
switch logging to proper usage

The logging methods do string interpolation themselves

From the reference:

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

  Logger.debug(msg, *args, **kwargs)

Logs a message with level DEBUG on this logger. The msg is the message format string, and the args are the arguments which are merged into msg using the string formatting operator. (Note that this means that you can use keywords in the format string, together with a single dictionary argument.)

There are two keyword arguments in kwargs which are inspected: exc_info which, if it does not evaluate as false, causes exception information to be added to the logging message. If an exception tuple (in the format returned by sys.exc_info()) is provided, it is used; otherwise, sys.exc_info() is called to get the exception informatio

The reason logging does string interpolation itselfs is to implement deferred interpolation.

String interpolation involves evaluating arguments, so it can introduce significant computation.  The logging module tries to be smart about deferring interpolation until the last possible moment.

The logging methods check isEnabledFor for the log level and won't interpolate if the level is not enabled.

https://github.com/python/cpython/blob/2.7/Lib/logging/__init__.py#L1178

     def warning(self, msg, *args, **kwargs):
        if self.isEnabledFor(WARNING):
            self._log(WARNING, msg, args, **kwargs)

logging actually waits to interpolate the string in LogRecord.getMessage()

https://github.com/python/cpython/blob/2.7/Lib/logging/__init__.py#L328
        if self.args:
            msg = msg % self.args

Change-Id: Ie09efe0a66881e19bd8119caa376075e605627a2
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
31 files changed:
yardstick/benchmark/contexts/node.py
yardstick/benchmark/runners/arithmetic.py
yardstick/benchmark/runners/base.py
yardstick/benchmark/runners/duration.py
yardstick/benchmark/runners/iteration.py
yardstick/benchmark/runners/sequence.py
yardstick/benchmark/scenarios/availability/actionrollbackers.py
yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py
yardstick/benchmark/scenarios/availability/attacker/attacker_general.py
yardstick/benchmark/scenarios/availability/attacker/attacker_process.py
yardstick/benchmark/scenarios/availability/attacker/baseattacker.py
yardstick/benchmark/scenarios/availability/director.py
yardstick/benchmark/scenarios/availability/monitor/basemonitor.py
yardstick/benchmark/scenarios/availability/monitor/monitor_command.py
yardstick/benchmark/scenarios/availability/monitor/monitor_general.py
yardstick/benchmark/scenarios/availability/monitor/monitor_process.py
yardstick/benchmark/scenarios/availability/operation/baseoperation.py
yardstick/benchmark/scenarios/availability/operation/operation_general.py
yardstick/benchmark/scenarios/availability/result_checker/baseresultchecker.py
yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py
yardstick/benchmark/scenarios/availability/scenario_general.py
yardstick/benchmark/scenarios/availability/serviceha.py
yardstick/benchmark/scenarios/compute/cachestat.py
yardstick/benchmark/scenarios/compute/cpuload.py
yardstick/benchmark/scenarios/compute/cyclictest.py
yardstick/benchmark/scenarios/compute/memload.py
yardstick/benchmark/scenarios/networking/netutilization.py
yardstick/benchmark/scenarios/storage/storperf.py
yardstick/dispatcher/http.py
yardstick/dispatcher/influxdb.py
yardstick/ssh.py