Post 1.3, Django has some niceÂ integrationÂ with the python logging module. It canÂ dictConfÂ to specify the formatters, handlers, etc. This is all pretty well documented here.
What wasn’t immediately obvious (to me anyway) was that you can use any of the handlers in django logging and pass the __init__ params to them in this config. So for example if you want to have a log which rotates everyday and keep a week of these files, then you can simply define:
# Other handlers here
'level' : 'DEBUG',
'formatter' : 'verbose', # from the django doc example
'class' : 'logging.handlers.TimedRotatingFileHandler',
'filename' : MY_LOG_FILENAME, # full path works
'when' : 'midnight',
'interval' : 1,
'backupCount' : 7,
and then use this handler for a logger:
# other loggers
You can use this logger in your app by grabbing the logger:
logger = logging.getLogger('my_logger')
And log away!
logger.warn("Here be Dragons!")
I have a small project to make a pretty simple windows GUI executable. In the past I have always used wxpython + py2exe for this kind of thing but decided to try something new.
After some poking around I settled on PySide which is the bindings for QT from Nokia. Its nice. Seems a little cleaner but actually pretty similar to wxPython in many ways.
At first I tried to use py2exe to make a single exe binary but I could never get this to work properly. The exe would always die somewhere during load and after spending too much time trying to sort that out I decided to use cx_freeze to much the same result. I also tried going back to Python 2.5 since that seems to have fewer MS DLL issues and PySide is available for that as well. Still no love.
Finally I tried Py-installer and it all pretty much worked right out of the box. Just go through the install step by step and you should be fine. Py-installer integrates with UpxÂ and my final exe came in at around 6MB.
If you are stuck with having to deploy an app on windows, you don’t need anything more that python, pyside and pyinstaller. As a bonus the app will also run on your real computer.