From 31ca4d455d1bbce69c6dc461dbd506b3523ac2d9 Mon Sep 17 00:00:00 2001 From: Dan Firth Date: Fri, 4 Oct 2013 13:18:23 +0000 Subject: Added chunkname prefix to some elements of the debug log. --- morphlib/app.py | 2 +- morphlib/builder2.py | 14 +++++++++----- morphlib/plugins/branch_and_merge_new_plugin.py | 2 +- morphlib/stagingarea.py | 6 +++--- morphlib/stagingarea_tests.py | 3 +++ morphlib/util.py | 8 ++++---- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/morphlib/app.py b/morphlib/app.py index a0833d45..6c39d38c 100644 --- a/morphlib/app.py +++ b/morphlib/app.py @@ -417,7 +417,7 @@ class Morph(cliapp.Application): # Log the environment. prev = getattr(self, 'prev_env', {}) - morphlib.util.log_dict_diff(kwargs['env'], prev) + morphlib.util.log_dict_diff(self, kwargs['env'], prev) self.prev_env = kwargs['env'] # run the command line diff --git a/morphlib/builder2.py b/morphlib/builder2.py index e1eaaa86..bab89aa2 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -439,8 +439,10 @@ class ChunkBuilder(BuilderBase): contents = morphlib.bins.chunk_contents(destdir, patterns) self.write_metadata(destdir, artifact_name, contents) - logging.debug('assembling chunk %s' % artifact_name) - logging.debug('assembling into %s' % f.name) + self.app.status(msg='assembling chunk %s' % artifact_name, + chatty=True) + self.app.status(msg='assembling into %s' % f.name, + chatty=True) self.app.status(msg='Creating chunk artifact %(name)s', name=artifact.name) morphlib.bins.create_chunk(destdir, f, patterns) @@ -700,8 +702,10 @@ class Builder(object): # pragma: no cover self.remote_artifact_cache, artifact, self.repo_cache, self.max_jobs, self.setup_mounts) - logging.debug('Builder.build: artifact %s with %s' % - (artifact.name, repr(o))) + self.app.status(msg='Builder.build: artifact %s with %s' % + (artifact.name, repr(o)), + chatty=True) built_artifacts = o.build_and_cache() - logging.debug('Builder.build: done') + self.app.status(msg='Builder.build: done', + chatty=True) return built_artifacts diff --git a/morphlib/plugins/branch_and_merge_new_plugin.py b/morphlib/plugins/branch_and_merge_new_plugin.py index 3d0a71a5..8cb5a7f9 100644 --- a/morphlib/plugins/branch_and_merge_new_plugin.py +++ b/morphlib/plugins/branch_and_merge_new_plugin.py @@ -832,7 +832,7 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin): system, metadata = self._load_system_metadata(metadata_path) resolved_refs = dict(self._resolve_refs_from_metadata(alias_resolver, metadata)) - logging.debug('Resolved refs: %r' % resolved_refs) + self.app.status(msg='Resolved refs: %r' % resolved_refs) base_ref = system['sha1'] # The previous version would fall back to deducing this from the repo # url and the repo alias resolver, but this does not always work, and diff --git a/morphlib/stagingarea.py b/morphlib/stagingarea.py index 7d034ff2..3cd3818c 100644 --- a/morphlib/stagingarea.py +++ b/morphlib/stagingarea.py @@ -156,8 +156,8 @@ class StagingArea(object): ''' - logging.debug('Installing artifact %s' % - getattr(handle, 'name', 'unknown name')) + self._app.status(msg='Installing artifact %s' % + getattr(handle, 'name', 'unknown name')) chunk_cache_dir = os.path.join(self._app.settings['tempdir'], 'chunks') unpacked_artifact = os.path.join( @@ -296,7 +296,7 @@ class StagingArea(object): if not self.use_chroot: do_not_mount_dirs += [temp_dir] - logging.debug("Not mounting dirs %r" % do_not_mount_dirs) + self._app.status(msg="Not mounting dirs %r" % do_not_mount_dirs) real_argv = ['linux-user-chroot', '--chdir', cwd, '--unshare-net'] for d in morphlib.fsutils.invert_paths(os.walk(chroot_dir), diff --git a/morphlib/stagingarea_tests.py b/morphlib/stagingarea_tests.py index 7cd4a5c3..27f85dff 100644 --- a/morphlib/stagingarea_tests.py +++ b/morphlib/stagingarea_tests.py @@ -57,6 +57,9 @@ class FakeApplication(object): def runcmd_unchecked(self, *args, **kwargs): return cliapp.runcmd_unchecked(*args, **kwargs) + def status(self, msg): + pass + class StagingAreaTests(unittest.TestCase): diff --git a/morphlib/util.py b/morphlib/util.py index 19c0046f..8a2cfd71 100644 --- a/morphlib/util.py +++ b/morphlib/util.py @@ -171,20 +171,20 @@ def new_repo_caches(app): # pragma: no cover return lrc, rrc -def log_dict_diff(cur, pre): # pragma: no cover +def log_dict_diff(app, cur, pre): # pragma: no cover '''Log the differences between two dicts to debug log''' dictA = cur dictB = pre for key in dictA.keys(): if key not in dictB: - logging.debug("New environment: %s = %s" % (key, dictA[key])) + app.status(msg="New environment: %s = %s" % (key, dictA[key])) elif dictA[key] != dictB[key]: - logging.debug( + app.status(msg= \ "Environment changed: %(key)s = %(valA)s to %(key)s = %(valB)s" % {"key": key, "valA": dictA[key], "valB": dictB[key]}) for key in dictB.keys(): if key not in dictA: - logging.debug("Environment removed: %s = %s" % (key, dictB[key])) + app.status(msg="Environment removed: %s = %s" % (key, dictB[key])) # This acquired from rdiff-backup which is GPLv2+ and a patch from 2011 -- cgit v1.2.1