[fix] log module was redifining constants thus breaking import

This commit is contained in:
Laurent Peuch 2017-01-02 03:53:15 +01:00
parent 4b62016d10
commit 93961e9aae
2 changed files with 14 additions and 10 deletions

View file

@ -160,13 +160,13 @@ class TTYHandler(logging.StreamHandler):
"""
LEVELS_COLOR = {
logging.NOTSET: 'white',
logging.DEBUG: 'white',
logging.INFO: 'cyan',
logging.SUCCESS: 'green',
logging.WARNING: 'yellow',
logging.ERROR: 'red',
logging.CRITICAL: 'red',
log.NOTSET: 'white',
log.DEBUG: 'white',
log.INFO: 'cyan',
log.SUCCESS: 'green',
log.WARNING: 'yellow',
log.ERROR: 'red',
log.CRITICAL: 'red',
}
def __init__(self, message_key='fmessage'):
@ -178,7 +178,7 @@ class TTYHandler(logging.StreamHandler):
msg = record.getMessage()
if self.supports_color():
level = ''
if self.level <= logging.DEBUG:
if self.level <= log.DEBUG:
# add level name before message
level = '%s ' % record.levelname
elif record.levelname in ['SUCCESS', 'WARNING', 'ERROR']:
@ -195,7 +195,7 @@ class TTYHandler(logging.StreamHandler):
def emit(self, record):
# set proper stream first
if record.levelno >= logging.WARNING:
if record.levelno >= log.WARNING:
self.stream = sys.stderr
else:
self.stream = sys.stdout

View file

@ -1,6 +1,10 @@
import os
import logging
from logging import addLevelName, setLoggerClass, Logger, getLogger
# import all constant because other modules tries to important them from this
# module because SUCCESS is defined in this module
from logging import (addLevelName, setLoggerClass, Logger, getLogger, NOTSET,
DEBUG, INFO, WARNING, ERROR, CRITICAL)
# Global configuration and functions -----------------------------------