Пример #1
0
    def p_log(self, msg, **kwargs):
        '''level = {info, warning, debug, error}
        '''
        logger = self

        if 'error' in kwargs:
            print 'error YES'
            kwargs['level'] = 'error'
        
        
        if 'level' in kwargs:
            level = kwargs['level']
        else:
            level = "info"

        if 'newline' in kwargs:
            for i in range(kwargs['newline']):
                eval("logger." + level + "(\"" + "\")")

        message = format_datetime(datetime.now(), "HH:mm:ss", locale='en')\
            + " (" + level + ") > "\
            + msg
        eval("logger." + level + "(\"" + message + "\")")
            
        if level == 'error':  # or whatever you want with more details
            message = ">> " + kwargs['error'][1].message  # exc_info()[1].message
            eval("logger." + level + "(\"" + message + "\")")
Пример #2
0
    def p_log(self, msg, **kwargs):
        '''level = {info, warning, debug, error}
        you can also use an exception=exc_info() argument to uprising exceptions!
        '''
        logger = self

        if 'error' in kwargs:
            print 'error YES'
            kwargs['level'] = 'error'
        
        if 'exception' in kwargs:
            print 'exception YES'
            kwargs['level'] = 'exception'

        if 'level' in kwargs:
            level = kwargs['level']
        else:
            level = "info"

        # warning: error must be a python error formating!
        if level == 'error':  # or whatever you want with more details
            message = ">> " + kwargs['error'][1].message  # exc_info()[1].message
            eval("logger." + level + "(\"" + message + "\")")
        
        elif level == 'exception':
            message = ">> UPRISING OF AN EXCEPTION!"
            eval("logger." + level + "(\"" + message + "\")")
            for line in format_exception(kwargs['exception'][0], kwargs['exception'][1], kwargs['exception'][2]):
                logger.error(line)

        else:
            if 'newline' in kwargs:
                for i in range(kwargs['newline']):
                    eval("logger." + level + "(\"" + "\")")

            if 'blank' in kwargs:
                if kwargs['blank']:
                    message = msg
            else:
                message = format_datetime(datetime.now(), "HH:mm:ss", locale='en')\
                    + " (" + level + ") > "\
                    + msg
            eval("logger." + level + "(\"" + message + "\")")