summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2016-05-19 18:54:18 +0200
committerArmin Ronacher <armin.ronacher@active-4.com>2016-05-19 18:54:18 +0200
commit75fd8e1883a8fc1014e1d30fce90aefc3901da87 (patch)
treec247a5703e4e212ff94cf09dd9dea908b429c9b2
parent520746d847682508e946811e8a05b2098079dadf (diff)
downloadraven-75fd8e1883a8fc1014e1d30fce90aefc3901da87.tar.gz
Streamlined the public breadcrumb api
-rw-r--r--raven/base.py4
-rw-r--r--raven/breadcrumbs.py25
-rw-r--r--raven/contrib/django/client.py2
3 files changed, 18 insertions, 13 deletions
diff --git a/raven/base.py b/raven/base.py
index 6c06d61..c07edce 100644
--- a/raven/base.py
+++ b/raven/base.py
@@ -831,14 +831,14 @@ class Client(object):
DeprecationWarning)
return self.context(**kwargs)
- def captureBreadcrumb(self, type, *args, **kwargs):
+ def captureBreadcrumb(self, *args, **kwargs):
"""Records a breadcrumb with the current context. They will be
sent with the next event.
"""
# Note: framework integration should not call this method but
# instead use the raven.breadcrumbs.record_breadcrumb function
# which will record to the correct client automatically.
- self.context.breadcrumbs.record(type, *args, **kwargs)
+ self.context.breadcrumbs.record(*args, **kwargs)
capture_breadcrumb = captureBreadcrumb
diff --git a/raven/breadcrumbs.py b/raven/breadcrumbs.py
index 6d298e9..fa11da3 100644
--- a/raven/breadcrumbs.py
+++ b/raven/breadcrumbs.py
@@ -30,12 +30,12 @@ class BreadcrumbBuffer(object):
self.buffer = []
self.limit = limit
- def record(self, type, timestamp=None, level=None, message=None,
- category=None, data=None, processor=None):
+ def record(self, timestamp=None, level=None, message=None,
+ category=None, data=None, type=None, processor=None):
if timestamp is None:
timestamp = time.time()
self.buffer.append(({
- 'type': type,
+ 'type': type or 'default',
'timestamp': timestamp,
'level': level,
'message': message,
@@ -74,13 +74,19 @@ def make_buffer(enabled=True):
return BlackholeBreadcrumbBuffer()
-def record_breadcrumb(type, timestamp=None, level=None,
- message=None, category=None, data=None,
- processor=None):
+def record_breadcrumb(type, *args, **kwargs):
+ # Legacy alias
+ kwargs['type'] = type
+ return record(*args, **kwargs)
+
+
+def record(message=None, timestamp=None, level=None, category=None,
+ data=None, type=None, processor=None):
"""Records a breadcrumb for all active clients. This is what integration
code should use rather than invoking the `captureBreadcrumb` method
on a specific client.
"""
+
if timestamp is None:
timestamp = time.time()
for ctx in raven.context.get_active_contexts():
@@ -118,7 +124,7 @@ def _record_log_breadcrumb(logger, level, msg, *args, **kwargs):
'level': logging.getLevelName(level).lower(),
'data': kwargs,
})
- record_breadcrumb('default', processor=processor)
+ record(processor=processor)
def _wrap_logging_method(meth, level=None):
@@ -261,7 +267,7 @@ def _hook_requests():
def send(self, request, *args, **kwargs):
def _record_request(response):
- record_breadcrumb('http', category='requests', data={
+ record(type='http', category='requests', data={
'url': request.url,
'method': request.method,
'status_code': response and response.status_code or None,
@@ -313,8 +319,7 @@ def _install_httplib():
}
data['data'].update(status)
return data
- record_breadcrumb('http', category='requests',
- processor=processor)
+ record(type='http', category='requests', processor=processor)
return real_putrequest(self, method, url, *args, **kwargs)
def getresponse(self, *args, **kwargs):
diff --git a/raven/contrib/django/client.py b/raven/contrib/django/client.py
index 00a555c..a031953 100644
--- a/raven/contrib/django/client.py
+++ b/raven/contrib/django/client.py
@@ -97,7 +97,7 @@ def install_sql_hook():
'duration': duration,
'category': 'query',
})
- breadcrumbs.record_breadcrumb('default', processor=processor)
+ breadcrumbs.record(processor=processor)
def record_many_sql(vendor, alias, start, sql, param_list):
duration = time.time() - start