Skip to content

Commit

Permalink
extra logging
Browse files Browse the repository at this point in the history
  • Loading branch information
smn committed Jul 17, 2015
1 parent 161a04b commit 1b3da5d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions consular/main.py
Expand Up @@ -62,25 +62,34 @@ def register_marathon_event_callback(self, events_url):
log.err('Consular event callback registration failed.')
returnValue(registered)

def log_http_response(self, response, method, path, data):
log.msg('%s %s with %s returned: %s' % (
method, path, data, response.code))
return response

def marathon_request(self, method, path, data=None):
return treq.request(
d = treq.request(
method, ('%s%s' % (self.marathon_endpoint, path)).encode('utf-8'),
headers={
'Content-Type': 'application/json',
'Accept': 'application/json',
},
data=(json.dumps(data) if data is not None else None),
pool=self.pool)
d.addCallback(self.log_http_response, method, path, data)
return d

def consul_request(self, method, path, data=None):
return treq.request(
d = treq.request(
method, ('%s%s' % (self.consul_endpoint, path)).encode('utf-8'),
headers={
'Content-Type': 'application/json',
'Accept': 'application/json',
},
data=(json.dumps(data) if data is not None else None),
pool=self.pool)
d.addCallback(self.log_http_response, method, path, data)
return d

@app.route('/')
def index(self, request):
Expand Down

0 comments on commit 1b3da5d

Please sign in to comment.