[FIX] reactive the colored logging
bzr revid: christophe@tinyerp.com-20090130165551-7e6nnn6f2xxabijd
This commit is contained in:
parent
8a3a776bbd
commit
27240361ca
|
@ -93,7 +93,8 @@ def init_logger():
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
# create a format for log messages and dates
|
# create a format for log messages and dates
|
||||||
formatter = logging.Formatter('[%(asctime)s] %(levelname)s:%(name)s:%(message)s', '%a %b %d %Y %H:%M:%S')
|
formatter = logging.Formatter('[%(asctime)s] %(levelname)s:%(name)s:%(message)s', '%a %b %d %Y %H:%M:%S')
|
||||||
|
|
||||||
|
logging_to_stdout = False
|
||||||
if tools.config['syslog']:
|
if tools.config['syslog']:
|
||||||
# SysLog Handler
|
# SysLog Handler
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
|
@ -113,11 +114,13 @@ def init_logger():
|
||||||
os.makedirs(dirname)
|
os.makedirs(dirname)
|
||||||
handler = logging.handlers.TimedRotatingFileHandler(logf,'D',1,30)
|
handler = logging.handlers.TimedRotatingFileHandler(logf,'D',1,30)
|
||||||
except Exception, ex:
|
except Exception, ex:
|
||||||
sys.stderr.write("ERROR: couldn't create the logfile directory\n")
|
sys.stderr.write("ERROR: couldn't create the logfile directory. Logging to the standard output.\n")
|
||||||
handler = logging.StreamHandler(sys.stdout)
|
handler = logging.StreamHandler(sys.stdout)
|
||||||
|
logging_to_stdout = True
|
||||||
else:
|
else:
|
||||||
# Normal Handler on standard output
|
# Normal Handler on standard output
|
||||||
handler = logging.StreamHandler(sys.stdout)
|
handler = logging.StreamHandler(sys.stdout)
|
||||||
|
logging_to_stdout = True
|
||||||
|
|
||||||
|
|
||||||
# tell the handler to use this format
|
# tell the handler to use this format
|
||||||
|
@ -127,7 +130,7 @@ def init_logger():
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
logger.setLevel(tools.config['log_level'] or '0')
|
logger.setLevel(tools.config['log_level'] or '0')
|
||||||
|
|
||||||
if handler is logging.StreamHandler and os.name != 'nt':
|
if logging_to_stdout and os.name != 'nt':
|
||||||
# change color of level names
|
# change color of level names
|
||||||
# uses of ANSI color codes
|
# uses of ANSI color codes
|
||||||
# see http://pueblo.sourceforge.net/doc/manual/ansi_color_codes.html
|
# see http://pueblo.sourceforge.net/doc/manual/ansi_color_codes.html
|
||||||
|
|
Loading…
Reference in New Issue