Logging

3 views
Skip to first unread message

cjparsons

unread,
Oct 15, 2008, 5:31:39 AM10/15/08
to web2py Web Framework
Are there any clever ways for debug logging? I am planning to use the
Python logger module to a file in the administration directory which I
guess will only be visible if logged in?

Thanks for any ideas you have

Chris

mdipierro

unread,
Oct 15, 2008, 9:26:06 AM10/15/08
to web2py Web Framework
Sorry Chirs, I do not understand what you mean by "debug logging". By
logging do you mean "logging in" or as in "logging module"?

cjparsons

unread,
Oct 15, 2008, 10:09:13 AM10/15/08
to web2py Web Framework

Ah, sorry. I mean logging module.

as in
logging.debug("request received with link")
or
logging.warning("session cookie contains invalid hash, logging out
user %r from host %r" % (user.id, ip_address))

BTW, thank you for putting up the early draft PDF if The Book. I can't
buy the soft copy because I'm running Linux and the hard copy doesn't
seem available here in the UK yet.

Chris
> > Chris- Hide quoted text -
>
> - Show quoted text -

mdipierro

unread,
Oct 15, 2008, 11:14:40 AM10/15/08
to web2py Web Framework
Got it now. Yes you can use the logging module and send messages to a
file but there is a major problem. I believe the parameters of the
logging module are per-process and not per-thread (please check). This
means if redirecting logging to a file, all web2py logging (for the
framework and all apps) will be redirected to the file. I think you
should just open('filename','w').write('log:%s' % message)
I also suggest log into
os.path.join(request.folder,'private','error.log') and create a custom
action to retrieve the log file. In this way you have per-app logging
and you can choose the permissions you need.

Perhaps there should be a logging command in web2py to avoid the
problems with the logging module.

Massimo

On Oct 15, 4:31 am, cjparsons <cjparso...@yahoo.co.uk> wrote:
Reply all
Reply to author
Forward
0 new messages