That will put an access log and error log into the
~/sites/$SITENAME
folder. Then we
add some debug calls in our
authenticate
function (again, we can do this directly on
the server):
accounts/authentication.py.
def
authenticate
(
self
,
assertion
):
logging
.
warning
(
'entering authenticate function'
)
response
=
requests
.
post
(
PERSONA_VERIFY_URL
,
data
=
{
'assertion'
:
assertion
,
'audience'
:
settings
.
DOMAIN
}
)
logging
.
warning
(
'got response from persona'
)
logging
.
warning
(
response
.
content
.
decode
())
[
...
]
Using the “root” logger like this (
logging.warning
) isn’t generally a
good idea. We’ll set up a more robust logging configuration at the end
of the chapter.
You should also make sure your
settings.py
still contains the
LOGGING
settings which will
actually send stuff to the console:
superlists/settings.py.
LOGGING
=
{
'version'
:
1
,
'disable_existing_loggers'
:
False
,
'handlers'
: {
'console'
: {
'level'
:
'DEBUG'
,
'class'
:
'logging.StreamHandler'
,
},
},
'loggers'
: {
'django'
: {
'handlers'
: [
'console'
],
},
},
'root'
: {
'level'
:
'INFO'
},
}
We restart Gunicorn again, and then either rerun the FT, or just try to log in manually.
While that happens, we can watch the logs on the server with a:
elspeth@server: $
tail -f error.log
# assumes we are in ~/sites/$SITENAME folder
[...]
WARNING:root:{"status":"failure","reason":"audience mismatch: domain mismatch"}
You may even find the page gets stuck in a “redirect loop”, as Persona tries to resubmit
the assertion again and again.
308
|
Chapter 17: Test Fixtures, Logging, and Server-Side Debugging