# -*- coding: utf8 -*-

from biocase.wrapper.errorclasses    import *
import logging


class DiagnosticMessage(object):
    def __init__(self, msg="", code=None, severity=None):
        self.msg=msg
        self.code=code
        self.severity=severity


class DiagnosticsHandler(logging.Handler):
    def __init__(self):
        self.diagnostics=[]
        logging.Handler.__init__(self)
        #self.setLevel(logging.WARN)
        
    def emit(self, record):
        d=DiagnosticMessage(msg=record.getMessage(), severity=record.levelname)
        self.diagnostics.append(d)