summaryrefslogtreecommitdiff
path: root/openstackclient/common/context.py
diff options
context:
space:
mode:
authorTerryHowe <terrylhowe@gmail.com>2015-08-09 06:26:56 -0600
committerTerryHowe <terrylhowe@gmail.com>2015-08-13 16:05:01 -0600
commit9c3c33639139ab319ca6d00925b34f9293ca81af (patch)
treef6474101c16988ee9e5a0c3c9e38dcc64f0bc0f8 /openstackclient/common/context.py
parente23dd6de5854fcc8ff76fe1b51eb46162770d9cc (diff)
downloadpython-openstackclient-9c3c33639139ab319ca6d00925b34f9293ca81af.tar.gz
Move set warnings filters to logging module
This is the first step in moving logging out of shell.py Change-Id: I3dcb4e17bb4687988ddf9b793ad1a308ef89b242 Implements: blueprint logging-migration
Diffstat (limited to 'openstackclient/common/context.py')
-rw-r--r--openstackclient/common/context.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/openstackclient/common/context.py b/openstackclient/common/context.py
index b7b16e94..348c5509 100644
--- a/openstackclient/common/context.py
+++ b/openstackclient/common/context.py
@@ -14,6 +14,7 @@
"""Context and Formatter"""
import logging
+import warnings
_LOG_MESSAGE_FORMAT = ('%(asctime)s.%(msecs)03d %(process)d '
'%(levelname)s %(name)s [%(clouds_name)s '
@@ -21,6 +22,15 @@ _LOG_MESSAGE_FORMAT = ('%(asctime)s.%(msecs)03d %(process)d '
_LOG_DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
+def set_warning_filter(log_level):
+ if log_level == logging.ERROR:
+ warnings.simplefilter("ignore")
+ elif log_level == logging.WARNING:
+ warnings.simplefilter("ignore")
+ elif log_level == logging.INFO:
+ warnings.simplefilter("once")
+
+
def setup_handler_logging_level(handler_type, level):
"""Setup of the handler for set the logging level