Previous boottool versions logged every single command that was run, but that was considered to be exceedingly verbose, because all of those commands and output/return would show in *.DEBUG files. Now, when running into bugs, we frequently have add log statements to the _run_* methods.
This patch checks an environment variable and logs debug messages if it is set. I chose to keep that as an extra knob, as casual users may want to see debug messages ('--verbose=5') but not every single command run and it's output/return code. Signed-off-by: Cleber Rosa <cr...@redhat.com> --- client/tools/boottool.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/client/tools/boottool.py b/client/tools/boottool.py index d50553d..41ca1db 100755 --- a/client/tools/boottool.py +++ b/client/tools/boottool.py @@ -706,6 +706,11 @@ class Grubby(object): self.opts = opts self.log = logging.getLogger(self.__class__.__name__) + if os.environ.has_key('BOOTTOOL_DEBUG_RUN'): + self.debug_run = True + else: + self.debug_run = False + self._check_grubby_version() self._set_bootloader() @@ -735,6 +740,9 @@ class Grubby(object): ''' Utility function that runs a command and returns command output ''' + if self.debug_run: + self.log.debug('running: "%s"', ' '.join(arguments)) + result = None try: result = subprocess.Popen(arguments, shell=False, @@ -746,6 +754,8 @@ class Grubby(object): if result is not None: result = result.strip() + if self.debug_run: + logging.debug('previous command output: "%s"', result) else: self.log.error('_run_get_output error while running: "%s"', ' '.join(arguments)) @@ -756,6 +766,9 @@ class Grubby(object): ''' Utility function that runs a command and returns command output ''' + if self.debug_run: + self.log.debug('running: "%s"', ' '.join(arguments)) + result = None try: result = subprocess.Popen(arguments, shell=False, @@ -768,6 +781,8 @@ class Grubby(object): if result is not None: result = result.strip() + if self.debug_run: + logging.debug('previous command output/error: "%s"', result) else: self.log.error('_run_get_output_err error while running: "%s"', ' '.join(arguments)) @@ -778,9 +793,14 @@ class Grubby(object): ''' Utility function that runs a command and returns status code ''' + if self.debug_run: + self.log.debug('running: "%s"', ' '.join(arguments)) + result = None try: result = subprocess.call(arguments) + if self.debug_run: + logging.debug('previous command result: %s', result) except OSError: result = -1 self.log.error('caught OSError, returning %s', result) @@ -1952,7 +1972,11 @@ class BoottoolApp(object): if level > max_level: level = max_level - logging_level = log_map.get(level) + if os.environ.has_key('BOOTTOOL_DEBUG_RUN'): + logging_level = logging.DEBUG + else: + logging_level = log_map.get(level) + logging.basicConfig(level=logging_level, format=LOGGING_FORMAT) -- 1.7.10.4 _______________________________________________ Autotest mailing list Autotest@test.kernel.org http://test.kernel.org/cgi-bin/mailman/listinfo/autotest