Karaage-Cluster/karaage — Issue #131: logging of text strings
Author: sorrison
Created: 2012-02-15 22:55:03+00:00
State: open

Have been thinking about the issue of logging in karaage, especially for gold and slurm stuff.

The most correct way seems to be to using the logging module. Unfortunately, django by default sets LOGGING to something that only handles ERRORs from django.request - and emails these to the administrator.

{{{
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
}}}

I would like to suggest karaage change this by default to something that captures a bit more, e.g.

{{{

LOGGING = {
'version': 1,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'console': {
'level':'INFO',
'class':'logging.StreamHandler',
'formatter': 'simple',
},
'file': {
'level':'DEBUG',
'class':'logging.handlers.TimedRotatingFileHandler',
'formatter': 'verbose',
'filename': '/tmp/karaage.log',
'when': 'D',
'interval': 1,
'backupCount': 14
},
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
}
},
'root': {
'handlers':['console', 'file', 'mail_admins'],
'level':'DEBUG',
},
}
}}}

Although I am not sure what where to send the log file; /tmp is probably not appropriate. Maybe syslog???

Also I noticed that this only works when the settings are initialized - by default this doesn't seem to happen in command line applications - setup_environ(settings) doesn't appear to do it - unless I include the following code:

{{{
import django.conf
django.conf.settings.LOGGING
}}}

which maybe deserves a bug against Django.

Any comments?