[SQL-CVS] r2589 - SQLObject/branches/0.9/docs
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2007-04-24 15:06:01
|
Author: phd
Date: 2007-04-24 09:05:55 -0600 (Tue, 24 Apr 2007)
New Revision: 2589
Modified:
SQLObject/branches/0.9/docs/SQLObject.txt
Log:
Added an example on how to configure logging.
Modified: SQLObject/branches/0.9/docs/SQLObject.txt
===================================================================
--- SQLObject/branches/0.9/docs/SQLObject.txt 2007-04-24 15:02:56 UTC (rev 2588)
+++ SQLObject/branches/0.9/docs/SQLObject.txt 2007-04-24 15:05:55 UTC (rev 2589)
@@ -1664,6 +1664,24 @@
uses prints instead of logging; `loglevel` can be "stdout" or "stderr" in
this case; default is "stdout".
+To configure logging one can do something like that::
+
+ import logging
+ logging.basicConfig()
+ for handler in logging.root.handlers[:]:
+ logging.root.removeHandler(handler)
+ handler = logging.FileHandler("test.log")
+ fmt = '[%(asctime)s] %(name)s %(levelname)s: %(message)s'
+ handler.setFormatter(logging.Formatter(fmt))
+ logging.root.addHandler(handler)
+ logging.root.setLevel(logging.DEBUG)
+ log = logging.getLogger("TEST")
+ log.info("Log started")
+
+ __connection__ = "sqlite:/:memory:?debug=1&logger=TEST&loglevel=debug"
+
+The code redirects SQLObject debug messages to the `test.log` file.
+
MySQL
-----
|