Merge lp:~bloodearnest/canonical-identity-provider/hi-fi-logging into lp:canonical-identity-provider/release

Proposed by Simon Davy
Status: Rejected
Rejected by: Simon Davy
Proposed branch: lp:~bloodearnest/canonical-identity-provider/hi-fi-logging
Merge into: lp:canonical-identity-provider/release
Diff against target: 91 lines (+7/-48)
3 files modified
Makefile (+1/-1)
django_project/settings_base.py (+1/-46)
requirements.txt (+5/-1)
To merge this branch: bzr merge lp:~bloodearnest/canonical-identity-provider/hi-fi-logging
Reviewer Review Type Date Requested Status
Canonical ISD hackers Pending
Review via email: mp+286877@code.launchpad.net

Description of the change

Use the new logging library, talisker:

https://code.launchpad.net/~bloodearnest/+junk/talisker

This library aims to standardise logging across our services, as well as provide structured logging. It does the following

 - a standard log format
 - arbitrary key=value pairs
 - log to stderr, for the charm to handle files, directories and perms, etc (12 factor app)

This change:

 - uses the gunicorn wrapper for make run, which sets up logging
 - disable django's default logging, as it's not needed any more (and has bad production defaults, see https://docs.djangoproject.com/en/1.8/topics/logging/#default-logging-configuration )

To post a comment you must log in.
1399. By Simon Davy

clean up whitespace

Revision history for this message
Maximiliano Bertacchini (maxiberta) :
Revision history for this message
Simon Davy (bloodearnest) wrote :

On Tue, Feb 23, 2016 at 4:34 PM, Maximiliano Bertacchini
<email address hidden> wrote:
>
>
> Diff comments:
>
>> === modified file 'Makefile'
>> --- Makefile 2016-01-21 15:45:34 +0000
>> +++ Makefile 2016-02-23 10:59:30 +0000
>> @@ -151,7 +151,7 @@
>>
>> run: ARGS=0.0.0.0:8000
>> run:
>> - $(ENV)/bin/gunicorn django_project.wsgi:application --workers=2 --reload --pid=logs/gunicorn.pid --bind=$(ARGS) --timeout=99999 --error-logfile=- --access-logfile=-
>> + $(ENV)/bin/talisker_gunicorn sso --devel -- django_project.wsgi:application --reload --pid logs/gunicorn.pid --access-logfile - --timeout 99999 --workers 2 --bind=$(ARGS)
>
> Is the --devel flag necessary?

For that makefile rule, yes. The defaults are production orientated,
and thus silence python's warning system (which is also what django's
default logging did before). --devel logs the warnings, which is what
we want in development, when this make target is designed to be used.

Thanks

--
Simon

Unmerged revisions

1399. By Simon Davy

clean up whitespace

1398. By Simon Davy

use explicit gunicorn version

1397. By Simon Davy

merging

1396. By Simon Davy

Remove manual wsgi wrapping

1395. By Simon Davy

merging

1394. By Simon Davy

Use new talisker runner

1393. By Simon Davy

basic talisker integration

1392. By Simon Davy

merging

1391. By Simon Davy

fix timezone formatting in access logger

1390. By Simon Davy

merging

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2016-01-21 15:45:34 +0000
3+++ Makefile 2016-02-23 10:59:30 +0000
4@@ -151,7 +151,7 @@
5
6 run: ARGS=0.0.0.0:8000
7 run:
8- $(ENV)/bin/gunicorn django_project.wsgi:application --workers=2 --reload --pid=logs/gunicorn.pid --bind=$(ARGS) --timeout=99999 --error-logfile=- --access-logfile=-
9+ $(ENV)/bin/talisker_gunicorn sso --devel -- django_project.wsgi:application --reload --pid logs/gunicorn.pid --access-logfile - --timeout 99999 --workers 2 --bind=$(ARGS)
10
11 start: bootstrap start-db
12
13
14=== modified file 'django_project/settings_base.py'
15--- django_project/settings_base.py 2016-01-27 12:00:39 +0000
16+++ django_project/settings_base.py 2016-02-23 10:59:30 +0000
17@@ -318,52 +318,7 @@
18 LOCALE_PATHS = [
19 os.path.join(BASE_DIR, 'branches/translations/locale'),
20 ]
21-LOGGING = {
22- 'disable_existing_loggers': False,
23- 'filters': {},
24- 'formatters': {
25- 'simple': {
26- 'datefmt': None,
27- 'format': '%(asctime)s %(levelname)s %(name)s %(message)s',
28- },
29- 'verbose': {
30- 'datefmt': None,
31- 'format': ('%(asctime)s %(levelname)s %(module)s %(process)d '
32- '%(thread)d %(message)s'),
33- },
34- },
35- 'handlers': {
36- 'file': {
37- 'filename': os.path.join(LOGS_DIR, 'sso.log'),
38- 'formatter': 'simple',
39- 'class': 'logging.FileHandler',
40- 'filters': '',
41- 'level': 'INFO',
42- },
43- },
44- 'incremental': False,
45- 'loggers': {
46- 'sso': {
47- 'level': 'INFO',
48- 'propagate': False,
49- 'filters': [],
50- 'handlers': ['file'],
51- },
52- 'django': {
53- 'level': 'INFO',
54- 'propagate': False,
55- 'filters': [],
56- 'handlers': ['file'],
57- },
58- },
59- 'root': {
60- 'level': 'INFO',
61- 'filters': [],
62- 'handlers': ['file'],
63- },
64- 'version': 1,
65-}
66-LOGGING_CONFIG = 'django.utils.log.dictConfig'
67+LOGGING_CONFIG = None
68 LOGIN_REDIRECT_URL = '/'
69 LOGIN_URL = '/+login'
70 LOGOUT_URL = '/accounts/logout/'
71
72=== modified file 'requirements.txt'
73--- requirements.txt 2016-02-01 15:30:36 +0000
74+++ requirements.txt 2016-02-23 10:59:30 +0000
75@@ -10,7 +10,6 @@
76 django-secure==1.0.1
77 django-statsd-mozilla==0.3.15
78 gargoyle==0.11.0
79-gunicorn==19.3.0
80 lazr.authentication==0.1.3
81 nexus==0.3.1
82 oath==1.4.0
83@@ -29,3 +28,8 @@
84 timeline==0.0.4
85 timeline-django==0.0.4
86 whitenoise==2.0.6
87+
88+# temporary talisker deps
89+talisker==0.1.0
90+gunicorn==19.4.5.dev1.690b11e
91+