Improve logging in CLI client

Do not output the INFO messages into the Console
Proper output of exceptions
"Wrong-Version" message displays proper service name
(we are grateful to Glance for providing a copy-paste source :)
but let's still call our service Application catalog, not Openstack Images )

Targets-blueprint: murano-cli-client

Change-Id: I484fa4d494584472f705fdffc35e2dc70f1f3e8a
This commit is contained in:
Alexander Tivelkov 2014-05-30 17:32:36 +04:00
parent 8615255f02
commit 0364228676
3 changed files with 17 additions and 4 deletions

View File

@ -56,7 +56,7 @@ class HTTPMultipleChoices(HTTPException):
code = 300
def __str__(self):
self.details = ("Requested version of OpenStack Images API is not"
self.details = ("Requested version of Application Catalog API is not "
"available.")
return "%s (HTTP %s) %s" % (self.__class__.__name__, self.code,
self.details)

View File

@ -15,13 +15,14 @@
from __future__ import print_function
import os
import prettytable
import sys
import textwrap
import uuid
import prettytable
import six
from muranoclient.common import exceptions
from muranoclient.openstack.common import importutils
from muranoclient.openstack.common import jsonutils
@ -143,3 +144,15 @@ def getsockopt(self, *args, **kwargs):
that use python-muranoclient also use newest eventlet
"""
return self.fd.getsockopt(*args, **kwargs)
def exception_to_str(exc):
try:
error = six.text_type(exc)
except UnicodeError:
try:
error = str(exc)
except UnicodeError:
error = ("Caught '%(exception)s' exception." %
{"exception": exc.__class__.__name__})
return strutils.safe_encode(error, errors='ignore')

View File

@ -200,7 +200,7 @@ class MuranoShell(object):
else:
logging.basicConfig(
format="%(levelname)s %(message)s",
level=logging.INFO)
level=logging.WARNING)
def main(self, argv):
# Parse args once to find version