Using the stream handler and just using our custom color printer.

This commit is contained in:
Joshua Harlow 2012-02-14 20:54:06 -08:00
parent ae48d1433c
commit d7f7c301b4
2 changed files with 2 additions and 23 deletions

View File

@ -14,9 +14,9 @@ formatter=form01
keys=hand01
[handler_hand01]
class=devstack.colorlog.TermHandler
class=devstack.log.StreamHandler
formatter=form01
args=()
args=(sys.stdout,)
[formatters]
keys=form01

View File

@ -15,11 +15,6 @@
# under the License.
import logging
import os
import sys
#requires http://pypi.python.org/pypi/termcolor
#but the colors make it worth it :-)
from termcolor import colored
COLOR_MAP = {
@ -48,19 +43,3 @@ class TermFormatter(logging.Formatter):
if attrs:
record.msg = colored(record.msg, attrs=attrs)
return logging.Formatter.format(self, record)
class TermHandler(logging.Handler):
STREAM = sys.stdout
DO_FLUSH = True
NL = os.linesep
def __init__(self):
logging.Handler.__init__(self)
def emit(self, record):
msg = self.format(record)
if msg is not None:
TermHandler.STREAM.write(msg + TermHandler.NL)
if TermHandler.DO_FLUSH:
TermHandler.STREAM.flush()