harvester-d4science/ckanext/harvest/log.py

16 lines
407 B
Python

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()
except:
pass