summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/common/logs.py46
-rw-r--r--openstackclient/tests/compute/v2/test_flavor.py10
-rw-r--r--openstackclient/tests/compute/v2/test_hypervisor.py6
-rw-r--r--openstackclient/tests/compute/v2/test_security_group.py6
-rw-r--r--openstackclient/tests/compute/v2/test_security_group_rule.py14
-rw-r--r--openstackclient/tests/compute/v2/test_server.py10
-rw-r--r--openstackclient/tests/compute/v2/test_service.py2
7 files changed, 61 insertions, 33 deletions
diff --git a/openstackclient/common/logs.py b/openstackclient/common/logs.py
index 6d1aec13..7ad6e832 100644
--- a/openstackclient/common/logs.py
+++ b/openstackclient/common/logs.py
@@ -18,6 +18,13 @@ import sys
import warnings
+def get_loggers():
+ loggers = {}
+ for logkey in logging.Logger.manager.loggerDict.keys():
+ loggers[logkey] = logging.getLevelName(logging.getLogger(logkey).level)
+ return loggers
+
+
def log_level_from_options(options):
# if --debug, --quiet or --verbose is not specified,
# the default logging level is warning
@@ -34,6 +41,17 @@ def log_level_from_options(options):
return log_level
+def log_level_from_string(level_string):
+ log_level = {
+ 'critical': logging.CRITICAL,
+ 'error': logging.ERROR,
+ 'warning': logging.WARNING,
+ 'info': logging.INFO,
+ 'debug': logging.DEBUG,
+ }.get(level_string, logging.WARNING)
+ return log_level
+
+
def log_level_from_config(config):
# Check the command line option
verbose_level = config.get('verbose_level')
@@ -49,15 +67,7 @@ def log_level_from_config(config):
verbose_level = 'info'
else:
verbose_level = 'debug'
-
- log_level = {
- 'critical': logging.CRITICAL,
- 'error': logging.ERROR,
- 'warning': logging.WARNING,
- 'info': logging.INFO,
- 'debug': logging.DEBUG,
- }.get(verbose_level, logging.WARNING)
- return log_level
+ return log_level_from_string(verbose_level)
def set_warning_filter(log_level):
@@ -168,3 +178,21 @@ class LogConfigurator(object):
self.file_logger.setFormatter(_FileFormatter(config=cloud_config))
self.file_logger.setLevel(log_level)
self.root_logger.addHandler(self.file_logger)
+
+ logconfig = cloud_config.config.get('logging', None)
+ if logconfig:
+ highest_level = logging.NOTSET
+ for k in logconfig.keys():
+ level = log_level_from_string(logconfig[k])
+ logging.getLogger(k).setLevel(level)
+ if (highest_level < level):
+ highest_level = level
+ self.console_logger.setLevel(highest_level)
+ if self.file_logger:
+ self.file_logger.setLevel(highest_level)
+ # loggers that are not set will use the handler level, so we
+ # need to set the global level for all the loggers
+ for logkey in logging.Logger.manager.loggerDict.keys():
+ logger = logging.getLogger(logkey)
+ if logger.level == logging.NOTSET:
+ logger.setLevel(log_level)
diff --git a/openstackclient/tests/compute/v2/test_flavor.py b/openstackclient/tests/compute/v2/test_flavor.py
index 9ae26962..bf78bee8 100644
--- a/openstackclient/tests/compute/v2/test_flavor.py
+++ b/openstackclient/tests/compute/v2/test_flavor.py
@@ -126,7 +126,7 @@ class TestFlavorList(TestFlavor):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class Lister in cliff, abstractmethod take_action()
+ # In base command class Lister in cliff, abstract method take_action()
# returns a tuple containing the column names and an iterable
# containing the data to be listed.
columns, data = self.cmd.take_action(parsed_args)
@@ -155,7 +155,7 @@ class TestFlavorList(TestFlavor):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class Lister in cliff, abstractmethod take_action()
+ # In base command class Lister in cliff, abstract method take_action()
# returns a tuple containing the column names and an iterable
# containing the data to be listed.
columns, data = self.cmd.take_action(parsed_args)
@@ -184,7 +184,7 @@ class TestFlavorList(TestFlavor):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class Lister in cliff, abstractmethod take_action()
+ # In base command class Lister in cliff, abstract method take_action()
# returns a tuple containing the column names and an iterable
# containing the data to be listed.
columns, data = self.cmd.take_action(parsed_args)
@@ -213,7 +213,7 @@ class TestFlavorList(TestFlavor):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class Lister in cliff, abstractmethod take_action()
+ # In base command class Lister in cliff, abstract method take_action()
# returns a tuple containing the column names and an iterable
# containing the data to be listed.
columns, data = self.cmd.take_action(parsed_args)
@@ -242,7 +242,7 @@ class TestFlavorList(TestFlavor):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class Lister in cliff, abstractmethod take_action()
+ # In base command class Lister in cliff, abstract method take_action()
# returns a tuple containing the column names and an iterable
# containing the data to be listed.
columns, data = self.cmd.take_action(parsed_args)
diff --git a/openstackclient/tests/compute/v2/test_hypervisor.py b/openstackclient/tests/compute/v2/test_hypervisor.py
index a11f59d2..8d717ba7 100644
--- a/openstackclient/tests/compute/v2/test_hypervisor.py
+++ b/openstackclient/tests/compute/v2/test_hypervisor.py
@@ -67,7 +67,7 @@ class TestHypervisorList(TestHypervisor):
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class Lister in cliff, abstractmethod take_action()
+ # In base command class Lister in cliff, abstract method take_action()
# returns a tuple containing the column names and an iterable
# containing the data to be listed.
columns, data = self.cmd.take_action(parsed_args)
@@ -94,7 +94,7 @@ class TestHypervisorList(TestHypervisor):
),
)
- # In base command class Lister in cliff, abstractmethod take_action()
+ # In base command class Lister in cliff, abstract method take_action()
# returns a tuple containing the column names and an iterable
# containing the data to be listed.
columns, data = self.cmd.take_action(parsed_args)
@@ -211,7 +211,7 @@ class TestHypervisorShow(TestHypervisor):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
diff --git a/openstackclient/tests/compute/v2/test_security_group.py b/openstackclient/tests/compute/v2/test_security_group.py
index 79eefe6c..c6998cb5 100644
--- a/openstackclient/tests/compute/v2/test_security_group.py
+++ b/openstackclient/tests/compute/v2/test_security_group.py
@@ -87,7 +87,7 @@ class TestSecurityGroupCreate(TestSecurityGroup):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
@@ -112,7 +112,7 @@ class TestSecurityGroupCreate(TestSecurityGroup):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
@@ -159,7 +159,7 @@ class TestSecurityGroupList(TestSecurityGroup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class Lister in cliff, abstractmethod take_action()
+ # In base command class Lister in cliff, abstract method take_action()
# returns a tuple containing the column names and an iterable
# containing the data to be listed.
columns, data = self.cmd.take_action(parsed_args)
diff --git a/openstackclient/tests/compute/v2/test_security_group_rule.py b/openstackclient/tests/compute/v2/test_security_group_rule.py
index d211ee4e..9a8003f3 100644
--- a/openstackclient/tests/compute/v2/test_security_group_rule.py
+++ b/openstackclient/tests/compute/v2/test_security_group_rule.py
@@ -149,7 +149,7 @@ class TestSecurityGroupRuleCreate(TestSecurityGroupRule):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
@@ -195,7 +195,7 @@ class TestSecurityGroupRuleCreate(TestSecurityGroupRule):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
@@ -245,7 +245,7 @@ class TestSecurityGroupRuleCreate(TestSecurityGroupRule):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
@@ -290,7 +290,7 @@ class TestSecurityGroupRuleCreate(TestSecurityGroupRule):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
@@ -338,7 +338,7 @@ class TestSecurityGroupRuleCreate(TestSecurityGroupRule):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
@@ -411,7 +411,7 @@ class TestSecurityGroupRuleList(TestSecurityGroupRule):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class Lister in cliff, abstractmethod take_action()
+ # In base command class Lister in cliff, abstract method take_action()
# returns a tuple containing the column names and an iterable
# containing the data to be listed.
columns, data = self.cmd.take_action(parsed_args)
@@ -449,7 +449,7 @@ class TestSecurityGroupRuleList(TestSecurityGroupRule):
parsed_args = self.check_parser(self.cmd, [], [])
- # In base command class Lister in cliff, abstractmethod take_action()
+ # In base command class Lister in cliff, abstract method take_action()
# returns a tuple containing the column names and an iterable
# containing the data to be listed.
columns, data = self.cmd.take_action(parsed_args)
diff --git a/openstackclient/tests/compute/v2/test_server.py b/openstackclient/tests/compute/v2/test_server.py
index 84402ea5..a80eaf51 100644
--- a/openstackclient/tests/compute/v2/test_server.py
+++ b/openstackclient/tests/compute/v2/test_server.py
@@ -163,7 +163,7 @@ class TestServerCreate(TestServer):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
@@ -243,7 +243,7 @@ class TestServerCreate(TestServer):
self.app.client_manager.network.find_network = find_network
self.app.client_manager.network.find_port = find_port
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
@@ -303,7 +303,7 @@ class TestServerCreate(TestServer):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
@@ -557,7 +557,7 @@ class TestServerImageCreate(TestServer):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
@@ -582,7 +582,7 @@ class TestServerImageCreate(TestServer):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class ShowOne in cliff, abstractmethod take_action()
+ # In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
# data to be shown.
columns, data = self.cmd.take_action(parsed_args)
diff --git a/openstackclient/tests/compute/v2/test_service.py b/openstackclient/tests/compute/v2/test_service.py
index 71700aa8..54adaab3 100644
--- a/openstackclient/tests/compute/v2/test_service.py
+++ b/openstackclient/tests/compute/v2/test_service.py
@@ -81,7 +81,7 @@ class TestServiceList(TestService):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- # In base command class Lister in cliff, abstractmethod take_action()
+ # In base command class Lister in cliff, abstract method take_action()
# returns a tuple containing the column names and an iterable
# containing the data to be listed.
self.cmd.take_action(parsed_args)