mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[fix] log module was redifining constants thus breaking import
This commit is contained in:
parent
4b62016d10
commit
93961e9aae
2 changed files with 14 additions and 10 deletions
|
@ -160,13 +160,13 @@ class TTYHandler(logging.StreamHandler):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
LEVELS_COLOR = {
|
LEVELS_COLOR = {
|
||||||
logging.NOTSET: 'white',
|
log.NOTSET: 'white',
|
||||||
logging.DEBUG: 'white',
|
log.DEBUG: 'white',
|
||||||
logging.INFO: 'cyan',
|
log.INFO: 'cyan',
|
||||||
logging.SUCCESS: 'green',
|
log.SUCCESS: 'green',
|
||||||
logging.WARNING: 'yellow',
|
log.WARNING: 'yellow',
|
||||||
logging.ERROR: 'red',
|
log.ERROR: 'red',
|
||||||
logging.CRITICAL: 'red',
|
log.CRITICAL: 'red',
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, message_key='fmessage'):
|
def __init__(self, message_key='fmessage'):
|
||||||
|
@ -178,7 +178,7 @@ class TTYHandler(logging.StreamHandler):
|
||||||
msg = record.getMessage()
|
msg = record.getMessage()
|
||||||
if self.supports_color():
|
if self.supports_color():
|
||||||
level = ''
|
level = ''
|
||||||
if self.level <= logging.DEBUG:
|
if self.level <= log.DEBUG:
|
||||||
# add level name before message
|
# add level name before message
|
||||||
level = '%s ' % record.levelname
|
level = '%s ' % record.levelname
|
||||||
elif record.levelname in ['SUCCESS', 'WARNING', 'ERROR']:
|
elif record.levelname in ['SUCCESS', 'WARNING', 'ERROR']:
|
||||||
|
@ -195,7 +195,7 @@ class TTYHandler(logging.StreamHandler):
|
||||||
|
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
# set proper stream first
|
# set proper stream first
|
||||||
if record.levelno >= logging.WARNING:
|
if record.levelno >= log.WARNING:
|
||||||
self.stream = sys.stderr
|
self.stream = sys.stderr
|
||||||
else:
|
else:
|
||||||
self.stream = sys.stdout
|
self.stream = sys.stdout
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import os
|
import os
|
||||||
import logging
|
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 -----------------------------------
|
# Global configuration and functions -----------------------------------
|
||||||
|
|
Loading…
Reference in a new issue