summaryrefslogtreecommitdiff
path: root/openstackclient/shell.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-09-09 20:15:54 +0000
committerGerrit Code Review <review@openstack.org>2015-09-09 20:15:54 +0000
commit46696f5ed55c9313754e7019e727ee88fa0847ce (patch)
tree1ff427cc41e180b0216178ea83416161cf3878e7 /openstackclient/shell.py
parentcd54db874154ab668fe7ecc34d247f1dac62896e (diff)
parent85a03945f0b5da0ec5778a929e08a641f427513a (diff)
downloadpython-openstackclient-46696f5ed55c9313754e7019e727ee88fa0847ce.tar.gz
Merge "Create log configuration class"
Diffstat (limited to 'openstackclient/shell.py')
-rw-r--r--openstackclient/shell.py61
1 files changed, 5 insertions, 56 deletions
diff --git a/openstackclient/shell.py b/openstackclient/shell.py
index 0623d82d..c08d619d 100644
--- a/openstackclient/shell.py
+++ b/openstackclient/shell.py
@@ -94,60 +94,12 @@ class OpenStackShell(app.App):
self.verify = True
self.client_manager = None
-
- # Operation log
- self.enable_operation_logging = False
self.command_options = None
def configure_logging(self):
- """Configure logging for the app
-
- Cliff sets some defaults we don't want so re-work it a bit
- """
-
- if self.options.debug:
- # --debug forces verbose_level 3
- # Set this here so cliff.app.configure_logging() can work
- self.options.verbose_level = 3
-
- super(OpenStackShell, self).configure_logging()
-
- # Set logging to the requested level
- log_level = context.log_level_from_options(self.options)
- context.set_warning_filter(log_level)
-
- # Set the handler logging level of FileHandler(--log-file)
- # and StreamHandler
- if self.options.log_file:
- context.setup_handler_logging_level(logging.FileHandler, log_level)
-
- context.setup_handler_logging_level(logging.StreamHandler, log_level)
-
- # Requests logs some stuff at INFO that we don't want
- # unless we have DEBUG
- requests_log = logging.getLogger("requests")
-
- # Other modules we don't want DEBUG output for
- cliff_log = logging.getLogger('cliff')
- stevedore_log = logging.getLogger('stevedore')
- iso8601_log = logging.getLogger("iso8601")
-
- if self.options.debug:
- # --debug forces traceback
- self.dump_stack_trace = True
- requests_log.setLevel(logging.DEBUG)
- else:
- self.dump_stack_trace = False
- requests_log.setLevel(logging.ERROR)
-
- cliff_log.setLevel(logging.ERROR)
- stevedore_log.setLevel(logging.ERROR)
- iso8601_log.setLevel(logging.ERROR)
-
- # Operation logging
- self.operation_log = logging.getLogger("operation_log")
- self.operation_log.setLevel(logging.ERROR)
- self.operation_log.propagate = False
+ """Configure logging for the app."""
+ self.log_configurator = context.LogConfigurator(self.options)
+ self.dump_stack_trace = self.log_configurator.dump_trace
def run(self, argv):
ret_val = 1
@@ -162,8 +114,6 @@ class OpenStackShell(app.App):
self.log.error(traceback.format_exc(e))
else:
self.log.error('Exception raised: ' + str(e))
- if self.enable_operation_logging:
- self.operation_log.error(traceback.format_exc(e))
return ret_val
@@ -287,9 +237,8 @@ class OpenStackShell(app.App):
argparse=self.options,
)
- # Set up every time record log in file and logging start
- context.setup_logging(self, self.cloud)
-
+ self.log_configurator.configure(self.cloud)
+ self.dump_stack_trace = self.log_configurator.dump_trace
self.log.info("START with options: %s", self.command_options)
self.log.debug("options: %s", self.options)
self.log.debug("defaults: %s", cc.defaults)