From 5b9acbb0addb420d97dabbf7e93b1b91c84c2c1b Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Mon, 7 Jul 2014 16:32:08 +0100 Subject: [archive] make archive debug logging depend on --debug This significantly reduces log noise at maximum verbosity. Users needing the interactive debugger can either use less verbosity (-v) or put up with the flood of messages. Fixes #319. Signed-off-by: Bryn M. Reeves --- sos/archive.py | 8 +++++++- sos/sosreport.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sos/archive.py b/sos/archive.py index 04b9ff43..a6394cfc 100644 --- a/sos/archive.py +++ b/sos/archive.py @@ -50,10 +50,14 @@ class Archive(object): log = logging.getLogger("sos") _name = "unset" + _debug = False def _format_msg(self,msg): return "[archive:%s] %s" % (self.archive_type(), msg) + def set_debug(self, debug): + self._debug = debug + def log_error(self, msg): self.log.error(self._format_msg(msg)) @@ -64,6 +68,8 @@ class Archive(object): self.log.info(self._format_msg(msg)) def log_debug(self, msg): + if not self._debug: + return self.log.debug(self._format_msg(msg)) # this is our contract to clients of the Archive class hierarchy. @@ -148,7 +154,7 @@ class FileCacheArchive(Archive): try: shutil.copy(src, dest) except IOError as e: - self.log_debug("caught '%s' copying '%s'" % (e, src)) + self.log_info("caught '%s' copying '%s'" % (e, src)) try: shutil.copystat(src, dest) except OSError: diff --git a/sos/sosreport.py b/sos/sosreport.py index bf3d5d5c..42a5f11e 100644 --- a/sos/sosreport.py +++ b/sos/sosreport.py @@ -568,6 +568,7 @@ class SoSReport(object): self.archive = ZipFileArchive(archive_name, self.tmpdir) else: self.archive = TarFileArchive(archive_name, self.tmpdir) + self.archive.set_debug(True if self.opts.debug else False) def _make_archive_paths(self): self.archive.makedirs(self.cmddir, 0o755) -- cgit