Commit 59abec6b authored by Stavros Sachtouris's avatar Stavros Sachtouris

Set default logger to astakosclient.AstakosClient

Fixes grnet/kamaki#58

This bug fix refers to the LoggedAstakosClient wrapper.
The class AstakosClient is not forced to use a default logger.
parent 9a77c621
......@@ -12,7 +12,8 @@ Bug fixes
---------
* Fix bug of incorrectly suppressed errors in "kamaki network create"
[grnet/kamaki#56]
[grnet/kamaki#56]
* Set a default logger to LoggedAstakosClient [grnet/kamaki#58]
v0.13rc4
========
......
......@@ -84,8 +84,8 @@ class AstakosClient(OriginalAstakosClient):
token = args.pop(0) if args else kwargs.pop('token', None)
args = tuple([token, url] + args)
else:
kwargs['auth_url'] = kwargs.get('auth_url', kwargs.get(
'endpoint_url', kwargs['base_url']))
kwargs.setdefault(
'auth_url', kwargs.get('endpoint_url', kwargs['base_url']))
# If no CA certificates are set, get the defaults from kamaki.defaults
if https.HTTPSClientAuthConnection.ca_file is None:
......@@ -130,6 +130,10 @@ class LoggedAstakosClient(AstakosClient):
LOG_TOKEN = False
LOG_DATA = False
def __init__(self, *args, **kwargs):
kwargs.setdefault('logger', log)
super(LoggedAstakosClient, self).__init__(*args, **kwargs)
def _dump_response(self, request, status, message, data):
recvlog.info('\n%d %s' % (status, message))
recvlog.info('data size: %s' % len(data))
......@@ -206,8 +210,7 @@ class CachedAstakosClient(Client):
:param token: (str) custom token to authenticate
"""
token = self._resolve_token(token)
astakos = LoggedAstakosClient(
self.endpoint_url, token, logger=getLogger('astakosclient'))
astakos = LoggedAstakosClient(self.endpoint_url, token, logger=log)
astakos.LOG_TOKEN = getattr(self, 'LOG_TOKEN', False)
astakos.LOG_DATA = getattr(self, 'LOG_DATA', False)
r = astakos.authenticate()
......
......@@ -32,7 +32,6 @@
# or implied, of GRNET S.A.
from mock import patch, call
from logging import getLogger
from unittest import TestCase
from itertools import product
......@@ -237,7 +236,7 @@ class CachedAstakosClient(TestCase):
self.assertEqual(example, self.client.authenticate('not important'))
resolve.assert_called_once_with('not important')
super_init.assert_called_once_with(
self.url, 'rtoken', logger=getLogger('astakosclient'))
self.url, 'rtoken', logger=astakos.log)
authenticate.assert_called_once_with()
uuid = example['access']['user']['id']
self.assertEqual(self.client._uuids['rtoken'], uuid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment