3rd iteration of logging cleanup.

This commit is contained in:
Darko Poljak 2017-06-29 09:22:59 +02:00 committed by Steven Armstrong
parent 127c05a882
commit a722f3c634
9 changed files with 15 additions and 14 deletions

View file

@ -464,6 +464,7 @@ class Config(object):
def object_prepare(self, cdist_object): def object_prepare(self, cdist_object):
"""Prepare object: Run type explorer + manifest""" """Prepare object: Run type explorer + manifest"""
self.log.info("Preparing object {}".format(cdist_object.name))
self.log.info( self.log.info(
"Running manifest and explorers for " + cdist_object.name) "Running manifest and explorers for " + cdist_object.name)
self.explorer.run_type_explorers(cdist_object) self.explorer.run_type_explorers(cdist_object)
@ -473,6 +474,7 @@ class Config(object):
def object_run(self, cdist_object): def object_run(self, cdist_object):
"""Run gencode and code for an object""" """Run gencode and code for an object"""
self.log.info("Running object " + cdist_object.name)
self.log.verbose("Trying to run object %s" % (cdist_object.name)) self.log.verbose("Trying to run object %s" % (cdist_object.name))
if cdist_object.state == core.CdistObject.STATE_DONE: if cdist_object.state == core.CdistObject.STATE_DONE:
raise cdist.Error(("Attempting to run an already finished " raise cdist.Error(("Attempting to run an already finished "
@ -481,7 +483,7 @@ class Config(object):
cdist_type = cdist_object.cdist_type cdist_type = cdist_object.cdist_type
# Generate # Generate
self.log.info("Generating code for %s" % (cdist_object.name)) self.log.debug("Generating code for %s" % (cdist_object.name))
cdist_object.code_local = self.code.run_gencode_local(cdist_object) cdist_object.code_local = self.code.run_gencode_local(cdist_object)
cdist_object.code_remote = self.code.run_gencode_remote(cdist_object) cdist_object.code_remote = self.code.run_gencode_remote(cdist_object)
if cdist_object.code_local or cdist_object.code_remote: if cdist_object.code_local or cdist_object.code_remote:
@ -492,8 +494,12 @@ class Config(object):
if cdist_object.code_local or cdist_object.code_remote: if cdist_object.code_local or cdist_object.code_remote:
self.log.info("Executing code for %s" % (cdist_object.name)) self.log.info("Executing code for %s" % (cdist_object.name))
if cdist_object.code_local: if cdist_object.code_local:
self.log.trace("Executing local code for %s"
% (cdist_object.name))
self.code.run_code_local(cdist_object) self.code.run_code_local(cdist_object)
if cdist_object.code_remote: if cdist_object.code_remote:
self.log.trace("Executing remote code for %s"
% (cdist_object.name))
self.code.transfer_code_remote(cdist_object) self.code.transfer_code_remote(cdist_object)
self.code.run_code_remote(cdist_object) self.code.run_code_remote(cdist_object)
else: else:

View file

@ -22,7 +22,6 @@
# #
import fnmatch import fnmatch
import logging
import os import os
import collections import collections
@ -30,8 +29,6 @@ import cdist
import cdist.core import cdist.core
from cdist.util import fsproperty from cdist.util import fsproperty
log = logging.getLogger(__name__)
class IllegalObjectIdError(cdist.Error): class IllegalObjectIdError(cdist.Error):
def __init__(self, object_id, message=None): def __init__(self, object_id, message=None):

View file

@ -21,7 +21,6 @@
# #
import os import os
import cdist import cdist

View file

@ -21,13 +21,10 @@
# #
# #
import logging
import os import os
import cdist import cdist
log = logging.getLogger(__name__)
''' '''
common: common:

View file

@ -168,6 +168,8 @@ class Explorer(object):
in the object. in the object.
""" """
self.log.info("Running type explorers for {}".format(
cdist_object.cdist_type))
self.log.trace("Transfering type explorers for type: %s", self.log.trace("Transfering type explorers for type: %s",
cdist_object.cdist_type) cdist_object.cdist_type)
self.transfer_type_explorers(cdist_object.cdist_type) self.transfer_type_explorers(cdist_object.cdist_type)

View file

@ -145,12 +145,11 @@ class Manifest(object):
else: else:
user_supplied = True user_supplied = True
self.log.info("Running initial manifest " + initial_manifest)
if not os.path.isfile(initial_manifest): if not os.path.isfile(initial_manifest):
raise NoInitialManifestError(initial_manifest, user_supplied) raise NoInitialManifestError(initial_manifest, user_supplied)
message_prefix = "initialmanifest" message_prefix = "initialmanifest"
self.log.info("Running initial manifest " + initial_manifest)
self.local.run_script(initial_manifest, self.local.run_script(initial_manifest,
env=self.env_initial_manifest(initial_manifest), env=self.env_initial_manifest(initial_manifest),
message_prefix=message_prefix, message_prefix=message_prefix,
@ -177,6 +176,7 @@ class Manifest(object):
cdist_object.cdist_type.manifest_path) cdist_object.cdist_type.manifest_path)
message_prefix = cdist_object.name message_prefix = cdist_object.name
if os.path.isfile(type_manifest): if os.path.isfile(type_manifest):
self.log.info("Running type manifest " + type_manifest)
self.local.run_script(type_manifest, self.local.run_script(type_manifest,
env=self.env_type_manifest(cdist_object), env=self.env_type_manifest(cdist_object),
message_prefix=message_prefix, message_prefix=message_prefix,

View file

@ -256,10 +256,10 @@ class Emulator(object):
# (this would leed to an circular dependency) # (this would leed to an circular dependency)
if ("CDIST_ORDER_DEPENDENCY" in self.env and if ("CDIST_ORDER_DEPENDENCY" in self.env and
'CDIST_OVERRIDE' not in self.env): 'CDIST_OVERRIDE' not in self.env):
# load object name created bevor this one from typeorder file ... # load object name created befor this one from typeorder file ...
with open(self.typeorder_path, 'r') as typecreationfile: with open(self.typeorder_path, 'r') as typecreationfile:
typecreationorder = typecreationfile.readlines() typecreationorder = typecreationfile.readlines()
# get the type created bevore this one ... # get the type created before this one ...
try: try:
lastcreatedtype = typecreationorder[-2].strip() lastcreatedtype = typecreationorder[-2].strip()
if 'require' in self.env: if 'require' in self.env:

View file

@ -192,7 +192,6 @@ class Local(object):
Return the output as a string. Return the output as a string.
""" """
self.log.trace("Local run: %s", command)
assert isinstance(command, (list, tuple)), ( assert isinstance(command, (list, tuple)), (
"list or tuple argument expected, got: %s" % command) "list or tuple argument expected, got: %s" % command)
@ -211,6 +210,7 @@ class Local(object):
message = cdist.message.Message(message_prefix, self.messages_path) message = cdist.message.Message(message_prefix, self.messages_path)
env.update(message.env) env.update(message.env)
self.log.trace("Local run: %s", command)
try: try:
if save_output: if save_output:
output, errout = exec_util.call_get_output(command, env=env) output, errout = exec_util.call_get_output(command, env=env)

View file

@ -45,7 +45,7 @@ def commandline():
log.warning(retval) log.warning(retval)
log.trace(args) log.trace(args)
log.verbose("version %s" % cdist.VERSION) log.info("version %s" % cdist.VERSION)
# Work around python 3.3 bug: # Work around python 3.3 bug:
# http://bugs.python.org/issue16308 # http://bugs.python.org/issue16308