summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/bonafide/session.py
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2017-04-25 18:00:12 +0200
committerKali Kaneko (leap communications) <kali@leap.se>2017-04-27 19:33:28 +0200
commit9f95446a55533c8cdceec7c4430be5cad752ecb1 (patch)
tree4265c127ee9b2c5f1e038836ad2e7b92ea0cad80 /src/leap/bitmask/bonafide/session.py
parent9a1548aa01996ce93febe0272f1f8e4dd5e130ff (diff)
[bug] unify logging style using class attr
I changed most of the logger statements to use a class attribute, in this way it's easier to identify which class it's logging them. in some cases I leave a module-level logger, when we're either using functions or when the module it's too small. at the same time I did a general review and cleanup of the logging statements.
Diffstat (limited to 'src/leap/bitmask/bonafide/session.py')
-rw-r--r--src/leap/bitmask/bonafide/session.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/leap/bitmask/bonafide/session.py b/src/leap/bitmask/bonafide/session.py
index 732afe53..551bfa2e 100644
--- a/src/leap/bitmask/bonafide/session.py
+++ b/src/leap/bitmask/bonafide/session.py
@@ -24,7 +24,6 @@ from leap.bitmask.bonafide import _srp
from leap.bitmask.bonafide import provider
from leap.bitmask.bonafide._http import httpRequest, cookieAgentFactory
-logger = Logger()
OK = 'ok'
@@ -45,6 +44,8 @@ def _auth_required(func):
class Session(object):
+ log = Logger()
+
def __init__(self, credentials, api, provider_cert):
# TODO check if an anonymous credentials is passed.
# TODO move provider_cert to api object.
@@ -91,7 +92,7 @@ class Session(object):
def authenticate(self):
uri = self._api.get_handshake_uri()
met = self._api.get_handshake_method()
- logger.debug("%s to %s" % (met, uri))
+ self.log.debug('%s to %s' % (met, uri))
params = self._srp_auth.get_handshake_params()
handshake = yield self._request(self._agent, uri, values=params,
@@ -101,7 +102,7 @@ class Session(object):
uri = self._api.get_authenticate_uri(login=self.username)
met = self._api.get_authenticate_method()
- logger.debug("%s to %s" % (met, uri))
+ self.log.debug('%s to %s' % (met, uri))
params = self._srp_auth.get_authentication_params()
auth = yield self._request(self._agent, uri, values=params,
@@ -119,9 +120,7 @@ class Session(object):
def logout(self):
uri = self._api.get_logout_uri()
met = self._api.get_logout_method()
- auth = yield self._request(self._agent, uri, method=met)
- print 'AUTH', auth
- print 'resetting user/pass'
+ yield self._request(self._agent, uri, method=met)
self.username = None
self.password = None
self._initialize_session()
@@ -211,6 +210,8 @@ if __name__ == "__main__":
import sys
from twisted.cred.credentials import UsernamePassword
+ log = Logger()
+
if len(sys.argv) != 4:
print "Usage:", sys.argv[0], "provider", "username", "password"
sys.exit()
@@ -229,7 +230,7 @@ if __name__ == "__main__":
reactor.stop()
def auth_eb(failure):
- logger.error(failure)
+ log.error(failure)
d = session.authenticate()
d.addCallback(print_result)