Using the stream handler and just using our custom color printer.
This commit is contained in:
parent
ae48d1433c
commit
d7f7c301b4
@ -14,9 +14,9 @@ formatter=form01
|
|||||||
keys=hand01
|
keys=hand01
|
||||||
|
|
||||||
[handler_hand01]
|
[handler_hand01]
|
||||||
class=devstack.colorlog.TermHandler
|
class=devstack.log.StreamHandler
|
||||||
formatter=form01
|
formatter=form01
|
||||||
args=()
|
args=(sys.stdout,)
|
||||||
|
|
||||||
[formatters]
|
[formatters]
|
||||||
keys=form01
|
keys=form01
|
||||||
|
@ -15,11 +15,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
#requires http://pypi.python.org/pypi/termcolor
|
|
||||||
#but the colors make it worth it :-)
|
|
||||||
from termcolor import colored
|
from termcolor import colored
|
||||||
|
|
||||||
COLOR_MAP = {
|
COLOR_MAP = {
|
||||||
@ -48,19 +43,3 @@ class TermFormatter(logging.Formatter):
|
|||||||
if attrs:
|
if attrs:
|
||||||
record.msg = colored(record.msg, attrs=attrs)
|
record.msg = colored(record.msg, attrs=attrs)
|
||||||
return logging.Formatter.format(self, record)
|
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()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user