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 <dusan.smit...@gmail.com> 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 sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to