Пример #1
0
def init_log(logLevel):
    l = log.getLogger()
    coloredlogs.install(
        level=log.getLevelName(logLevel),
        logger=l,
        fmt='[%(asctime)s] %(levelname)-8s %(name)s %(message)s',
        field_styles={
            'asctime': {
                'color': 'white'
            },
            'levelname': {
                'color': 'white',
                'bold': True
            }
        },
        level_styles={
            'verbose': {
                'color': 'black',
                'bright': True
            },
            'debug': {},
            'info': {
                'color': 'cyan',
                'bright': True
            },
            'warning': {
                'color': 'yellow'
            },
            'error': {
                'color': 'red',
                'bright': True
            },
            'critical': {
                'color': 'red',
                'bright': True
            },
            'notice': {
                'color': 'magenta'
            },
            'spam': {
                'color': 'green',
                'faint': True
            },
            'success': {
                'color': 'green',
                'bright': True,
                'bold': True
            },
        })

    log.getLogger('requests').setLevel(log.WARN)
    log.getLogger('urllib3').setLevel(log.WARN)

    fh = log.FileHandler("server.log")
    fh.setLevel(logLevel)
    formatter = log.Formatter(
        '[%(asctime)s] %(levelname)-8s %(name)s %(message)s')
    fh.setFormatter(formatter)
    l.addHandler(fh)
Пример #2
0
 def testGetLevelName(self):
     self.assertEquals('ERROR', log.getLevelName(1))
     self.assertEquals('WARN', log.getLevelName(2))
     self.assertEquals('INFO', log.getLevelName(3))
     self.assertEquals('DEBUG', log.getLevelName(4))
     self.assertEquals('LOG', log.getLevelName(5))
Пример #3
0
 def __init__(self, group, level):
     name = log.getLevelName(level).capitalize()
     super(LevelRadioButton, self).__init__(group, name, not group)
     self.level = level
Пример #4
0
 def testGetLevelName(self):
     self.assertEquals('ERROR', log.getLevelName(1))
     self.assertEquals('WARN', log.getLevelName(2))
     self.assertEquals('INFO', log.getLevelName(3))
     self.assertEquals('DEBUG', log.getLevelName(4))
     self.assertEquals('LOG', log.getLevelName(5))
Пример #5
0
 def __init__(self, group, level):
     name = log.getLevelName(level).capitalize()
     super(LevelRadioButton, self).__init__(group, name, not group)
     self.level = level
Пример #6
0
 def testGetLevelName(self):
     self.assertEquals("ERROR", log.getLevelName(1))
     self.assertEquals("WARN", log.getLevelName(2))
     self.assertEquals("INFO", log.getLevelName(3))
     self.assertEquals("DEBUG", log.getLevelName(4))
     self.assertEquals("LOG", log.getLevelName(5))