#140 Fix logging-not-lazy pylint warnings
Merged 6 years ago by dcallagh. Opened 6 years ago by csomh.
csomh/greenwave fix-logging-not-lazy  into  master

@@ -111,8 +111,8 @@ 

              for rule in policy.rules:

                  if rule.test_case_name == testcase:

                      applicable_policies.add(policy)

-         log.debug("messaging: found %i applicable policies of %i for testcase %r" % (

-             len(applicable_policies), len(config['policies']), testcase))

+         log.debug("messaging: found %i applicable policies of %i for testcase %r",

+                   len(applicable_policies), len(config['policies']), testcase)

  

          # Given all of our applicable policies, build a map of all decision

          # context we know about, and which product versions they relate to.
@@ -120,7 +120,7 @@ 

          for policy in applicable_policies:

              versions = set(policy.product_versions)

              decision_contexts[policy.decision_context].update(versions)

-         log.debug("messaging: found %i decision contexts" % len(decision_contexts))

+         log.debug("messaging: found %i decision contexts", len(decision_contexts))

  

          # For every context X version combination, ask greenwave if this new

          # result pushes any decisions over a threshold.

file modified
+3 -3
@@ -76,17 +76,17 @@ 

      else:

          default_config_file = '/etc/greenwave/settings.py'

  

-     log.debug("config: Loading config from %r" % config_obj)

+     log.debug("config: Loading config from %r", config_obj)

      config.from_object(config_obj)

  

      config_file = os.environ.get('GREENWAVE_CONFIG', default_config_file)

-     log.debug("config: Extending config with %r" % config_file)

+     log.debug("config: Extending config with %r", config_file)

      config.from_pyfile(config_file)

  

      if os.environ.get('SECRET_KEY'):

          config['SECRET_KEY'] = os.environ['SECRET_KEY']

  

-     log.debug("config: Loading policies from %r" % config['POLICIES_DIR'])

+     log.debug("config: Loading policies from %r", config['POLICIES_DIR'])

      config['policies'] = load_policies(config['POLICIES_DIR'])

  

      return config

As I've learnt, this avoids string interpolation in case
logs are not printed due to the loglevel set.

This can save a few CPU cycles, and make CI pass this step.

Signed-off-by: Hunor Csomortáni csomh@redhat.com

Pull-Request has been merged by dcallagh

6 years ago