summaryrefslogtreecommitdiff
path: root/openstackclient/common/context.py
diff options
context:
space:
mode:
authorTerryHowe <terrylhowe@gmail.com>2015-08-09 07:01:18 -0600
committerTerryHowe <terrylhowe@gmail.com>2015-08-13 16:11:25 -0600
commitca9965c3282d028da52ec465d5024f16fb54ba04 (patch)
tree9e09966948fbc5fb873b38f12f1214bd088016c7 /openstackclient/common/context.py
parent9c3c33639139ab319ca6d00925b34f9293ca81af (diff)
downloadpython-openstackclient-ca9965c3282d028da52ec465d5024f16fb54ba04.tar.gz
Move options to log level out of shell.py
Move the conversion of command line options to log level out of shell.py. Change-Id: I86cb45a85cd63927aa1c87c1eed27542981df659 Implements: blueprint logging-migration
Diffstat (limited to 'openstackclient/common/context.py')
-rw-r--r--openstackclient/common/context.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/openstackclient/common/context.py b/openstackclient/common/context.py
index 348c5509..70c85943 100644
--- a/openstackclient/common/context.py
+++ b/openstackclient/common/context.py
@@ -22,6 +22,22 @@ _LOG_MESSAGE_FORMAT = ('%(asctime)s.%(msecs)03d %(process)d '
_LOG_DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
+def log_level_from_options(options):
+ # if --debug, --quiet or --verbose is not specified,
+ # the default logging level is warning
+ log_level = logging.WARNING
+ if options.verbose_level == 0:
+ # --quiet
+ log_level = logging.ERROR
+ elif options.verbose_level == 2:
+ # One --verbose
+ log_level = logging.INFO
+ elif options.verbose_level >= 3:
+ # Two or more --verbose
+ log_level = logging.DEBUG
+ return log_level
+
+
def set_warning_filter(log_level):
if log_level == logging.ERROR:
warnings.simplefilter("ignore")