Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small fixes to get example_project working #1

Merged
5 commits merged into from
Sep 1, 2010
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ Logs Django exceptions to your database handler.

(This is a major refactor of django-db-log and is not backwards compatible)

============
Requirements
============

- **postgresql**
- **Django >= 1.2** (to use a secondary database to store error logs)
- **pygooglechart** (to generate *optional* error reports)

=========
Upgrading
=========
Expand Down Expand Up @@ -47,19 +55,19 @@ Configuration

Several options exist to configure django-sentry via your ``settings.py``:

######################
#######################
SENTRY_CATCH_404_ERRORS
######################
#######################

Enable catching of 404 errors in the logs. Default value is ``False``::

SENTRY_CATCH_404_ERRORS = True

You can skip other custom exception types by adding a ``skip_sentry = True`` attribute to them.

####################
#####################
SENTRY_DATABASE_USING
####################
#####################

Use a secondary database to store error logs. This is useful if you have several websites and want to aggregate error logs onto one database server::

Expand All @@ -73,13 +81,12 @@ You should also enable the ``DBLogRouter`` to avoid things like extraneous table
...
]

Some things to note:

* This functionality REQUIRES Django 1.2.
.. note:: This functionality REQUIRES Django 1.2.

#############
##############
SENTRY_LOGGING
#############
##############

Enabling this setting will turn off automatic database logging within the exception handler, and instead send all exceptions to the named logger ``sentry``. Use this in conjuction with ``sentry.handlers.DBLogHandler`` or your own handler to tweak how logging is dealt with.

Expand Down
4 changes: 3 additions & 1 deletion example_project/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os.path

import sys
# Django settings for example_project project.

DEBUG = False
Expand All @@ -13,6 +13,8 @@

PROJECT_ROOT = os.path.dirname(__file__)

sys.path.insert(0, os.path.abspath(os.path.join(PROJECT_ROOT, '..')))

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
Expand Down
56 changes: 32 additions & 24 deletions sentry/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
from math import log
import datetime

try:
from pygooglechart import SimpleLineChart
except ImportError:
SimpleLineChart = None

# TODO: login
from django.db.models import Count
from django.http import HttpResponse, HttpResponseForbidden
Expand All @@ -11,10 +19,6 @@
from sentry.models import GroupedMessage, Message, LOG_LEVELS
from sentry.templatetags.sentry_helpers import with_priority

from math import log
from pygooglechart import SimpleLineChart, Axis

import datetime

def index(request):
logger_names = SortedDict((l, l) for l in GroupedMessage.objects.values_list('logger', flat=True).distinct())
Expand Down Expand Up @@ -75,16 +79,18 @@ def index(request):
max_y = max(rows.values())
else:
max_y = 1
chart = SimpleLineChart(384, 80, y_range=[0, max_y])
chart.add_data([max_y]*30)
chart.add_data([rows.get((today-datetime.timedelta(hours=d)).hour, 0) for d in range(0, 24)][::-1])
chart.add_data([0]*30)
chart.fill_solid(chart.BACKGROUND, 'eeeeee')
chart.add_fill_range('eeeeee', 0, 1)
chart.add_fill_range('e0ebff', 1, 2)
chart.set_colours(['eeeeee', '999999', 'eeeeee'])
chart.set_line_style(1, 1)
chart_url = chart.get_url()

if SimpleLineChart:
chart = SimpleLineChart(384, 80, y_range=[0, max_y])
chart.add_data([max_y]*30)
chart.add_data([rows.get((today-datetime.timedelta(hours=d)).hour, 0) for d in range(0, 24)][::-1])
chart.add_data([0]*30)
chart.fill_solid(chart.BACKGROUND, 'eeeeee')
chart.add_fill_range('eeeeee', 0, 1)
chart.add_fill_range('e0ebff', 1, 2)
chart.set_colours(['eeeeee', '999999', 'eeeeee'])
chart.set_line_style(1, 1)
chart_url = chart.get_url()

return render_to_response('sentry/index.html', locals())

Expand Down Expand Up @@ -193,15 +199,17 @@ def group(request, group_id):
max_y = max(rows.values())
else:
max_y = 1
chart = SimpleLineChart(384, 80, y_range=[0, max_y])
chart.add_data([max_y]*30)
chart.add_data([rows.get((today-datetime.timedelta(hours=d)).hour, 0) for d in range(0, 24)][::-1])
chart.add_data([0]*30)
chart.fill_solid(chart.BACKGROUND, 'eeeeee')
chart.add_fill_range('eeeeee', 0, 1)
chart.add_fill_range('e0ebff', 1, 2)
chart.set_colours(['eeeeee', '999999', 'eeeeee'])
chart.set_line_style(1, 1)
chart_url = chart.get_url()

if SimpleLineChart:
chart = SimpleLineChart(384, 80, y_range=[0, max_y])
chart.add_data([max_y]*30)
chart.add_data([rows.get((today-datetime.timedelta(hours=d)).hour, 0) for d in range(0, 24)][::-1])
chart.add_data([0]*30)
chart.fill_solid(chart.BACKGROUND, 'eeeeee')
chart.add_fill_range('eeeeee', 0, 1)
chart.add_fill_range('e0ebff', 1, 2)
chart.set_colours(['eeeeee', '999999', 'eeeeee'])
chart.set_line_style(1, 1)
chart_url = chart.get_url()

return render_to_response('sentry/group.html', locals())