Merge lp:~james-w/pkgme-service/log-oopses into lp:pkgme-service

Proposed by James Westby
Status: Merged
Approved by: Jonathan Lange
Approved revision: 40
Merged at revision: 39
Proposed branch: lp:~james-w/pkgme-service/log-oopses
Merge into: lp:pkgme-service
Diff against target: 145 lines (+69/-3)
9 files modified
.bzrignore (+1/-0)
dev_config/templates/production_credentials.cfg.erb (+6/-0)
django_project/dev.cfg (+6/-0)
django_project/main.cfg (+35/-0)
django_project/production_credentials.cfg.example (+6/-0)
src/djpkgme/templates/404.html (+5/-0)
src/djpkgme/templates/500.html (+5/-0)
src/djpkgme/urls.py (+1/-0)
src/djpkgme/views.py (+4/-3)
To merge this branch: bzr merge lp:~james-w/pkgme-service/log-oopses
Reviewer Review Type Date Requested Status
Jonathan Lange (community) Approve
Review via email: mp+89999@code.launchpad.net

Commit message

Add the configuration to have django errors logged to a file.

Description of the change

Hi,

This adds the configuration for django's logging framework to log
everything at WARNING or higher to a log file.

It also does a couple of things that will help with using this:

  * Adds /pkgme/+oops URL that generates an exception on purpose.
  * Adds a template for 404 so that they don't turn in to 500s
  * Adds a template for 500 so that we know what the real exception is, not
    the one that says "You don't have a 500.html template."

This will require some co-ordination with IS around deployment so that the
config is in place first, and the config needs to be created by puppet
so that it can point to the right log dir. I'll propose a branch to add
this to the template.

Thanks,

James

To post a comment you must log in.
lp:~james-w/pkgme-service/log-oopses updated
39. By James Westby

Also add the stanza to the dev_config template.

40. By James Westby

Reset debug.

Revision history for this message
Jonathan Lange (jml) wrote :

Looks good.

Why do we set the log dir for Django in the example credentials, but set the output directory for pkgme in the production.cfg?

Is there some wiki page we should update for tricky deployments?

review: Approve
Revision history for this message
James Westby (james-w) wrote :

On Wed, 25 Jan 2012 13:57:44 -0000, Jonathan Lange <email address hidden> wrote:
> Review: Approve
>
> Looks good.
>
> Why do we set the log dir for Django in the example credentials, but set the output directory for pkgme in the production.cfg?

We have to set the log dir in the production_credentials as it will
change depending on the instance (production/staging), so it should be
managed by puppet.

The fact that the output directory is the same for pkgme is a bit of an
oddity I guess.

> Is there some wiki page we should update for tricky deployments?

https://wiki.canonical.com/InformationInfrastructure/WebOps/CA/PkgmeServiceProductionStatus

I'll update it when the branch lands and I have the revno.

Thanks,

James

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2012-01-13 01:03:04 +0000
+++ .bzrignore 2012-01-24 21:19:23 +0000
@@ -9,3 +9,4 @@
9sourcecode/*9sourcecode/*
10django_project/production_paths.py10django_project/production_paths.py
11django_project/production_credentials.cfg11django_project/production_credentials.cfg
12django.log
1213
=== modified file 'dev_config/templates/production_credentials.cfg.erb'
--- dev_config/templates/production_credentials.cfg.erb 2012-01-18 23:45:14 +0000
+++ dev_config/templates/production_credentials.cfg.erb 2012-01-24 21:19:23 +0000
@@ -25,3 +25,9 @@
25myapps_consumer_key = 25myapps_consumer_key =
26myapps_token = 26myapps_token =
27myapps_token_secret = 27myapps_token_secret =
28
29[django_file_logging_handler]
30level = WARNING
31class = logging.handlers.WatchedFileHandler
32formatter = verbose
33filename = <%= basedir %>/django.log
2834
=== modified file 'django_project/dev.cfg'
--- django_project/dev.cfg 2012-01-09 22:52:57 +0000
+++ django_project/dev.cfg 2012-01-24 21:19:23 +0000
@@ -15,6 +15,12 @@
15 djkombu15 djkombu
16databases = databases16databases = databases
1717
18[django_file_logging_handler]
19level = WARNING
20class = logging.handlers.WatchedFileHandler
21formatter = verbose
22filename = django.log
23
18[databases]24[databases]
19default = default_database25default = default_database
2026
2127
=== modified file 'django_project/main.cfg'
--- django_project/main.cfg 2012-01-10 14:33:32 +0000
+++ django_project/main.cfg 2012-01-24 21:19:23 +0000
@@ -33,3 +33,38 @@
33 django.contrib.messages.middleware.MessageMiddleware33 django.contrib.messages.middleware.MessageMiddleware
34root_urlconf = django_project.urls34root_urlconf = django_project.urls
35test_runner = djcelery.contrib.test_runner.CeleryTestSuiteRunner35test_runner = djcelery.contrib.test_runner.CeleryTestSuiteRunner
36logging = django_logging
37
38[django_logging]
39version = 1
40disable_existing_loggers = True
41formatters = django_logging_formatters
42handlers = django_logging_handlers
43loggers = django_logging_loggers
44root = django_logging_root
45
46[django_logging_root]
47level = WARNING
48
49[django_logging_loggers]
50django = django_logger
51
52[django_logger]
53handlers = file
54level = WARNING
55
56[django_logging_handlers]
57file = django_file_logging_handler
58null = django_null_logging_handler
59
60[django_null_logging_handler]
61level = DEBUG
62class = django.utils.log.NullHandler
63
64[django_logging_formatters]
65verbose = django_verbose_logging_formatter
66
67[django_verbose_logging_formatter]
68# Double escaped as configglue interpolates once, and we need the rest to survive
69# until django interpolates.
70format = %%(levelname)s %%(asctime)s %%(module)s %%(process)d %%(thread)d %%(message)s
3671
=== modified file 'django_project/production_credentials.cfg.example'
--- django_project/production_credentials.cfg.example 2012-01-09 22:52:57 +0000
+++ django_project/production_credentials.cfg.example 2012-01-24 21:19:23 +0000
@@ -31,3 +31,9 @@
31myapps_consumer_key =31myapps_consumer_key =
32myapps_token =32myapps_token =
33myapps_token_secret =33myapps_token_secret =
34
35[django_file_logging_handler]
36level = WARNING
37class = logging.handlers.WatchedFileHandler
38formatter = verbose
39filename = /var/log/pkgme-service/django.log
3440
=== added directory 'src/djpkgme/templates'
=== added file 'src/djpkgme/templates/404.html'
--- src/djpkgme/templates/404.html 1970-01-01 00:00:00 +0000
+++ src/djpkgme/templates/404.html 2012-01-24 21:19:23 +0000
@@ -0,0 +1,5 @@
1<html>
2 <body>
3 <h1>Not Found</h1>
4 </body>
5</html>
06
=== added file 'src/djpkgme/templates/500.html'
--- src/djpkgme/templates/500.html 1970-01-01 00:00:00 +0000
+++ src/djpkgme/templates/500.html 2012-01-24 21:19:23 +0000
@@ -0,0 +1,5 @@
1<html>
2<body>
3 <h1>Error</h1>
4</body>
5</html>
06
=== modified file 'src/djpkgme/urls.py'
--- src/djpkgme/urls.py 2011-08-31 19:37:43 +0000
+++ src/djpkgme/urls.py 2012-01-24 21:19:23 +0000
@@ -5,5 +5,6 @@
55
6urlpatterns = patterns('',6urlpatterns = patterns('',
7 url(r'^$', views.index),7 url(r'^$', views.index),
8 url(r'^\+oops$', views.oops),
8 url(r'^api/', include(djpkgme.api.urls)),9 url(r'^api/', include(djpkgme.api.urls)),
9)10)
1011
=== modified file 'src/djpkgme/views.py'
--- src/djpkgme/views.py 2011-11-28 17:20:42 +0000
+++ src/djpkgme/views.py 2012-01-24 21:19:23 +0000
@@ -1,8 +1,9 @@
1from django.http import HttpResponseRedirect, HttpResponse1from django.http import HttpResponse
2
3from .tasks import GuessPackagingDetailsTask
42
5ALL_CLEAR = 'Hello world!'3ALL_CLEAR = 'Hello world!'
64
7def index(request):5def index(request):
8 return HttpResponse(ALL_CLEAR)6 return HttpResponse(ALL_CLEAR)
7
8def oops(request):
9 raise AssertionError("Manually generated OOPS")

Subscribers

People subscribed via source and target branches