From 826102c0b55d08aa5128fc7ca91cc24951fac87b Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Tue, 30 Jun 2020 08:58:40 +0100 Subject: [PATCH] Logging: Fixes issue #241 --- volatility/cli/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/volatility/cli/__init__.py b/volatility/cli/__init__.py index 513741e6c..98097f7f0 100644 --- a/volatility/cli/__init__.py +++ b/volatility/cli/__init__.py @@ -31,13 +31,11 @@ from volatility.framework.configuration import requirements # Make sure we log everything vollog = logging.getLogger() -vollog.setLevel(1) -# Trim the console down by default console = logging.StreamHandler() console.setLevel(logging.WARNING) formatter = logging.Formatter('%(levelname)-8s %(name)-12s: %(message)s') +# Trim the console down by default console.setFormatter(formatter) -vollog.addHandler(console) class PrintedProgress(object): @@ -72,8 +70,15 @@ class CommandLine(interfaces.plugins.FileConsumerInterface): """Constructs a command-line interface object for users to run plugins.""" def __init__(self): + self.setup_logging() self.output_dir = None + @classmethod + def setup_logging(cls): + # Delay the setting of vollog for those that want to import volatility.cli (issue #241) + vollog.setLevel(1) + vollog.addHandler(console) + def run(self): """Executes the command line module, taking the system arguments, determining the plugin to run and then running it."""