Skip to content

Commit

Permalink
Deprecate exception/message and use captureEventTYpe instead
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Feb 4, 2012
1 parent 4320892 commit 3d5b272
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.3.5

* Moved exception and message methods to capture{Exception,Message}.
* Added captureQuery method.

1.3.4

* Corrected duplicate DSN behavior in Django client.
Expand Down
2 changes: 1 addition & 1 deletion docs/config/django.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You'll be referencing the client slightly differently in Django as well::
from raven.contrib.django.models import get_client

client = get_client()
client.capture(....)
client.captureException()

Integration with ``logging``
----------------------------
Expand Down
30 changes: 20 additions & 10 deletions raven/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Client(object):
>>> try:
>>> 1/0
>>> except ZeroDivisionError:
>>> ident = client.get_ident(client.capture('Exception'))
>>> ident = client.get_ident(client.captureException())
>>> print "Exception caught; reference is %%s" %% ident
"""
logger = logging.getLogger('raven')
Expand Down Expand Up @@ -369,28 +369,30 @@ def decode(self, data):
return json.loads(base64.b64decode(data).decode('zlib'))

def create_from_text(self, *args, **kwargs):
warnings.warn("create_from_text is deprecated. Use message() instead.", DeprecationWarning)
return self.message(*args, **kwargs)
warnings.warn("create_from_text is deprecated. Use captureMessage() instead.", DeprecationWarning)
return self.captureMessage(*args, **kwargs)
message = create_from_text

def create_from_exception(self, *args, **kwargs):
warnings.warn("create_from_exception is deprecated. Use exception() instead.", DeprecationWarning)
return self.exception(*args, **kwargs)
warnings.warn("create_from_exception is deprecated. Use captureException() instead.", DeprecationWarning)
return self.captureException(*args, **kwargs)
exception = create_from_exception

def message(self, message, **kwargs):
def captureMessage(self, message, **kwargs):
"""
Creates an event for from ``message``.
Creates an event from ``message``.
>>> client.message('My event just happened!')
>>> client.captureMessage('My event just happened!')
"""
return self.capture('Message', message=message, **kwargs)

def exception(self, exc_info=None, **kwargs):
def captureException(self, exc_info=None, **kwargs):
"""
Creates an event from an exception.
>>> try:
>>> exc_info = sys.exc_info()
>>> client.exception(exc_info)
>>> client.captureException(exc_info)
>>> finally:
>>> del exc_info
Expand All @@ -400,6 +402,14 @@ def exception(self, exc_info=None, **kwargs):
"""
return self.capture('Exception', exc_info=exc_info, **kwargs)

def captureQuery(self, query, params=(), engine=None, **kwargs):
"""
Creates an event for a SQL query.
>>> client.catureQuery('SELECT * FROM foo')
"""
return self.capture('Query', query=query, params=params, engine=engine, **kwargs)


class DummyClient(Client):
"Sends messages into an empty void"
Expand Down
2 changes: 1 addition & 1 deletion raven/scripts/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main():
sys.exit(1)

print 'Sending a test message...',
ident = client.get_ident(client.message('This is a test message generated using ``raven test``'))
ident = client.get_ident(client.captureMessage('This is a test message generated using ``raven test``'))
print 'success!'
print
print 'The test message can be viewed at the following URL:'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

setup(
name='raven',
version='1.3.4',
version='1.3.5',
author='David Cramer',
author_email='[email protected]',
url='http://github.com/dcramer/raven',
Expand Down

0 comments on commit 3d5b272

Please sign in to comment.