2016-04-05 20:21:04 +02:00
|
|
|
from logging import Handler
|
|
|
|
|
|
|
|
from ckanext.harvest.model import HarvestLog
|
|
|
|
|
|
|
|
class DBLogHandler(Handler, object):
|
|
|
|
def __init__(self):
|
|
|
|
super(DBLogHandler,self).__init__()
|
|
|
|
|
|
|
|
def emit(self, record):
|
|
|
|
try:
|
|
|
|
level = record.levelname
|
|
|
|
msg = self.format(record)
|
|
|
|
obj = HarvestLog(level=level, content=msg)
|
|
|
|
obj.save()
|
2016-04-25 19:53:49 +02:00
|
|
|
except Exception as exc:
|
2016-04-05 20:21:04 +02:00
|
|
|
pass
|