aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-07-07 16:32:08 +0100
committerBryn M. Reeves <bmr@redhat.com>2014-07-07 16:33:22 +0100
commit5b9acbb0addb420d97dabbf7e93b1b91c84c2c1b (patch)
treed17bba4cf7afd9cc4961f7790f3b0beea24a0aba
parent10e5987331faf35628357f29d7a21e5d386c8c3c (diff)
downloadsos-5b9acbb0addb420d97dabbf7e93b1b91c84c2c1b.tar.gz
[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 <bmr@redhat.com>
-rw-r--r--sos/archive.py8
-rw-r--r--sos/sosreport.py1
2 files changed, 8 insertions, 1 deletions
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)