From 93961e9aae0dc03a0631cf15cd9ab2ffc0562ec7 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 2 Jan 2017 03:53:15 +0100 Subject: [PATCH] [fix] log module was redifining constants thus breaking import --- moulinette/interfaces/cli.py | 18 +++++++++--------- moulinette/utils/log.py | 6 +++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/moulinette/interfaces/cli.py b/moulinette/interfaces/cli.py index e9307d9a..ada6697d 100644 --- a/moulinette/interfaces/cli.py +++ b/moulinette/interfaces/cli.py @@ -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 diff --git a/moulinette/utils/log.py b/moulinette/utils/log.py index 5b2844de..47c13a1e 100644 --- a/moulinette/utils/log.py +++ b/moulinette/utils/log.py @@ -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 -----------------------------------