This is my working version. Its a modification of the DBHandler found
here:
http://stackoverflow.com/questions/935930/creating-a-logging-handler-to-connect-to-oracle/
class SqlAlchemyHandler(logging.Handler):
def __init__(self, session):
logging.Handler.__init__(self)
self.session = session
def emit(self, record):
try:
#use default formatting
self.format(record)
self.session.add(ProcessLog(record.levelname,
record.message))
except Exception, inst:
print inst
def close(self):
self.session.commit()
logging.Handler.close(self)
On 17 jul., 23:07, dusans <[email protected]> wrote:
> Does anyone have a custom handler for the logging module that would
> use a sqlalchemy connection to save the log into the db.
>
> Tnx :)
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.