Skip to content

Commit

Permalink
Added some logging so I can see what's going on during PSHB callbcaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobian committed Jun 29, 2011
1 parent f1305fc commit 8d26c69
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
9 changes: 8 additions & 1 deletion django_website/aggregator/models.py
@@ -1,10 +1,13 @@
import logging
import datetime
from django.db import models
from django.contrib.auth.models import User
from django.conf import settings
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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions 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
Expand All @@ -14,6 +15,7 @@ def index(request):
"""
Displays the latest feeds of each type.
"""
logging.getLogger('django_website.foobar').info('sdfasdf')

This comment has been minimized.

Copy link
@FloridSleeves

FloridSleeves Nov 19, 2019

What's this 'sdfasdf' for? Is it a random logging for testing?

ctx = {'feedtype_list': FeedType.objects.all()}
return render(request, 'aggregator/index.html', ctx)

Expand Down
43 changes: 43 additions & 0 deletions django_website/settings/www.py
Expand Up @@ -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

Expand Down

0 comments on commit 8d26c69

Please sign in to comment.