eventlog is a simple app that provides an easy and clean interface for logging diagnostic as well as business intelligence data about activity that occurs in your site.
Out of the box using this does write to the database.
For small sites, it should be good enough to use inline but you might at some point want to consider wrapping calls to the log() method and queue them in a job manager like celery or pyres so that the calls become asynchronous.
Documentation can be found at http://eventlog.rtfd.org/
This app, and many others like it, have been built in support of many of Eldarion's own sites, and sites of our clients. We would love to help you on your next project so get in touch by dropping us a note at firstname.lastname@example.org.