Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added some logging so I can see what's going on during PSHB callbcaks.

  • Loading branch information...
commit 8d26c69505a181d3f45b16745c57c5192e490852 1 parent f1305fc
@jacobian jacobian authored
View
9 django_website/aggregator/models.py
@@ -1,3 +1,4 @@
+import logging
import datetime
from django.db import models
from django.contrib.auth.models import User
@@ -5,6 +6,8 @@
from django_push.subscriber import signals as push_signals
from django_push.subscriber.models import Subscription
+log = logging.getLogger(__name__)
+
class FeedType(models.Model):
name = models.CharField(max_length=250)
slug = models.SlugField(max_length=250)
@@ -52,10 +55,13 @@ def create_or_update_by_guid(self, guid, **kwargs):
except self.model.DoesNotExist:
# Create a new item
+ log.debug('Creating entry: %s', guid)
kwargs['guid'] = guid
item = self.create(**kwargs)
else:
+ log.debug('Updating entry: %s', guid)
+
# Update an existing one.
kwargs.pop('feed', None)
@@ -88,10 +94,11 @@ def get_absolute_url(self):
return self.link
def feed_updated(sender, notification, **kwargs):
+ log.debug('Recieved notification: %s', sender.topic)
try:
feed = Feed.objects.get(feed_url=sender.topic)
except Feed.DoesNotExist:
- return
+ log.error('Got notified about a non-existant feed: %s', sender.topic)
for entry in notification.entries:
title = entry.title
View
2  django_website/aggregator/views.py
@@ -1,5 +1,6 @@
from __future__ import absolute_import
+import logging
from django.shortcuts import render_to_response, get_object_or_404, redirect
from django.template import RequestContext
from django.contrib.auth.decorators import login_required
@@ -14,6 +15,7 @@ def index(request):
"""
Displays the latest feeds of each type.
"""
+ logging.getLogger('django_website.foobar').info('sdfasdf')
ctx = {'feedtype_list': FeedType.objects.all()}
return render(request, 'aggregator/index.html', ctx)
View
43 django_website/settings/www.py
@@ -100,6 +100,49 @@
DEFAULT_FROM_EMAIL = "noreply@djangoproject.com"
+LOGGING = {
+ "version": 1,
+ "disable_existing_loggers": True,
+ "formatters": {
+ "simple": {"format": "[%(name)s] %(levelname)s: %(message)s"},
+ "full": {"format": "%(asctime)s [%(name)s] %(levelname)s: %(message)s"}
+ },
+ "handlers": {
+ "mail_admins": {
+ "level": "ERROR",
+ "class": "django.utils.log.AdminEmailHandler",
+ },
+ "console": {
+ "level": "DEBUG",
+ "class": "logging.StreamHandler",
+ "formatter": "simple",
+ },
+ },
+ "loggers": {
+ "django.request": {
+ "handlers": ["mail_admins"],
+ "level": "ERROR",
+ "propagate": False,
+ },
+ "django_website": {
+ "handlers": ["console"],
+ "level": "DEBUG",
+ }
+ }
+}
+if PRODUCTION:
+ LOGGING["handlers"]["logfile"] = {
+ "formatter": "full",
+ "level": "DEBUG",
+ "class": "logging.handlers.TimedRotatingFileHandler",
+ "filename": "/var/log/django_website.log",
+ "when": "D",
+ "interval": 7,
+ "backupCount": 5,
+ }
+ LOGGING["loggers"]["django.request"]["handlers"].append("logfile")
+ LOGGING["loggers"]["django_website"]["handlers"] = ["logfile"]
+
# django-registration settings
ACCOUNT_ACTIVATION_DAYS = 3
Please sign in to comment.
Something went wrong with that request. Please try again.