Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 8d26c69505a181d3f45b16745c57c5192e490852 1 parent f1305fc
Jacob Kaplan-Moss authored June 29, 2011
9  django_website/aggregator/models.py
... ...
@@ -1,3 +1,4 @@
  1
+import logging
1 2
 import datetime
2 3
 from django.db import models
3 4
 from django.contrib.auth.models import User
@@ -5,6 +6,8 @@
5 6
 from django_push.subscriber import signals as push_signals
6 7
 from django_push.subscriber.models import Subscription
7 8
 
  9
+log = logging.getLogger(__name__)
  10
+
8 11
 class FeedType(models.Model):
9 12
     name = models.CharField(max_length=250)
10 13
     slug = models.SlugField(max_length=250)
@@ -52,10 +55,13 @@ def create_or_update_by_guid(self, guid, **kwargs):
52 55
         
53 56
         except self.model.DoesNotExist:
54 57
             # Create a new item
  58
+            log.debug('Creating entry: %s', guid)
55 59
             kwargs['guid'] = guid
56 60
             item = self.create(**kwargs)
57 61
             
58 62
         else:
  63
+            log.debug('Updating entry: %s', guid)
  64
+
59 65
             # Update an existing one.
60 66
             kwargs.pop('feed', None)
61 67
             
@@ -88,10 +94,11 @@ def get_absolute_url(self):
88 94
         return self.link
89 95
 
90 96
 def feed_updated(sender, notification, **kwargs):
  97
+    log.debug('Recieved notification: %s', sender.topic)
91 98
     try:
92 99
         feed = Feed.objects.get(feed_url=sender.topic)
93 100
     except Feed.DoesNotExist:
94  
-        return
  101
+        log.error('Got notified about a non-existant feed: %s', sender.topic)
95 102
         
96 103
     for entry in notification.entries:
97 104
         title = entry.title
2  django_website/aggregator/views.py
... ...
@@ -1,5 +1,6 @@
1 1
 from __future__ import absolute_import
2 2
 
  3
+import logging
3 4
 from django.shortcuts import render_to_response, get_object_or_404, redirect
4 5
 from django.template import RequestContext
5 6
 from django.contrib.auth.decorators import login_required
@@ -14,6 +15,7 @@ def index(request):
14 15
     """
15 16
     Displays the latest feeds of each type.
16 17
     """
  18
+    logging.getLogger('django_website.foobar').info('sdfasdf')
17 19
     ctx = {'feedtype_list': FeedType.objects.all()}
18 20
     return render(request, 'aggregator/index.html', ctx)
19 21
 
43  django_website/settings/www.py
@@ -100,6 +100,49 @@
100 100
 
101 101
 DEFAULT_FROM_EMAIL = "noreply@djangoproject.com"
102 102
 
  103
+LOGGING = {
  104
+    "version": 1,
  105
+    "disable_existing_loggers": True,
  106
+    "formatters": {
  107
+        "simple": {"format": "[%(name)s] %(levelname)s: %(message)s"},
  108
+        "full": {"format": "%(asctime)s [%(name)s] %(levelname)s: %(message)s"}
  109
+    },
  110
+    "handlers": {
  111
+        "mail_admins": {
  112
+            "level": "ERROR",
  113
+            "class": "django.utils.log.AdminEmailHandler",
  114
+        },
  115
+        "console": {
  116
+            "level": "DEBUG",
  117
+            "class": "logging.StreamHandler",
  118
+            "formatter": "simple",
  119
+        },
  120
+    },
  121
+    "loggers": {
  122
+        "django.request": {
  123
+            "handlers": ["mail_admins"],
  124
+            "level": "ERROR",
  125
+            "propagate": False,
  126
+        },
  127
+        "django_website": {
  128
+            "handlers": ["console"],
  129
+            "level": "DEBUG",
  130
+        }
  131
+    }
  132
+}
  133
+if PRODUCTION:
  134
+    LOGGING["handlers"]["logfile"] = {
  135
+        "formatter": "full",
  136
+        "level": "DEBUG",
  137
+        "class": "logging.handlers.TimedRotatingFileHandler",
  138
+        "filename": "/var/log/django_website.log",
  139
+        "when": "D",
  140
+        "interval": 7,
  141
+        "backupCount": 5,
  142
+    }
  143
+    LOGGING["loggers"]["django.request"]["handlers"].append("logfile")
  144
+    LOGGING["loggers"]["django_website"]["handlers"] = ["logfile"]
  145
+
103 146
 # django-registration settings
104 147
 ACCOUNT_ACTIVATION_DAYS = 3
105 148
 

0 notes on commit 8d26c69

Please sign in to comment.
Something went wrong with that request. Please try again.