forked from getsentry/raven-python
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored Django settings and the logging integration, as well as a …
…few minor fixes
- Loading branch information
Showing
16 changed files
with
129 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
raven.contrib.django.logging | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
:copyright: (c) 2010 by the Sentry Team, see AUTHORS for more details. | ||
:license: BSD, see LICENSE for more details. | ||
""" | ||
|
||
from __future__ import absolute_import | ||
|
||
import logging | ||
import sys | ||
import traceback | ||
|
||
class SentryHandler(logging.Handler): | ||
def emit(self, record): | ||
from raven.contrib.django.middleware import SentryLogMiddleware | ||
from raven.contrib.django.models import get_client | ||
|
||
# Fetch the request from a threadlocal variable, if available | ||
request = getattr(SentryLogMiddleware.thread, 'request', None) | ||
|
||
self.format(record) | ||
|
||
# Avoid typical config issues by overriding loggers behavior | ||
if record.name.startswith('sentry.errors'): | ||
print >> sys.stderr, "Recursive log message sent to SentryHandler" | ||
print >> sys.stderr, record.message | ||
return | ||
|
||
self.format(record) | ||
try: | ||
get_client().create_from_record(record, request=request) | ||
except Exception: | ||
print >> sys.stderr, "Top level Sentry exception caught - failed creating log record" | ||
print >> sys.stderr, record.msg | ||
print >> sys.stderr, traceback.format_exc() | ||
return | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
from __future__ import absolute_import | ||
|
||
from django.db import models | ||
from sentry.models import GzippedDictField | ||
|
||
class TestModel(models.Model): | ||
data = GzippedDictField(blank=True, null=True) | ||
|
||
def __unicode__(self): | ||
return unicode(self.data) | ||
|
||
class DuplicateKeyModel(models.Model): | ||
foo = models.IntegerField(unique=True, default=1) | ||
|
||
def __unicode__(self): | ||
return unicode(self.foo) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from __future__ import absolute_import | ||
|
||
from django.conf.urls.defaults import * | ||
|
||
urlpatterns = patterns('', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters