提交 8863766f 编写于 作者: sangshuduo's avatar sangshuduo

make print output be python2 and python3 compatible.

上级 9d13fd24
......@@ -15,6 +15,7 @@ import sys
import os
import time
import datetime
from distutils.log import warn as printf
class TDLog:
......@@ -22,27 +23,27 @@ class TDLog:
self.path = ""
def info(self, info):
print("%s %s" % (datetime.datetime.now(), info))
printf("%s %s" % (datetime.datetime.now(), info))
def sleep(self, sec):
print("%s sleep %d seconds" % (datetime.datetime.now(), sec))
printf("%s sleep %d seconds" % (datetime.datetime.now(), sec))
time.sleep(sec)
def debug(self, err):
print("\033[1;36m%s %s\033[0m" % (datetime.datetime.now(), err))
printf("\033[1;36m%s %s\033[0m" % (datetime.datetime.now(), err))
def success(self, info):
print("\033[1;32m%s %s\033[0m" % (datetime.datetime.now(), info))
printf("\033[1;32m%s %s\033[0m" % (datetime.datetime.now(), info))
def notice(self, err):
print("\033[1;33m%s %s\033[0m" % (datetime.datetime.now(), err))
printf("\033[1;33m%s %s\033[0m" % (datetime.datetime.now(), err))
def exit(self, err):
print("\033[1;31m%s %s\033[0m" % (datetime.datetime.now(), err))
printf("\033[1;31m%s %s\033[0m" % (datetime.datetime.now(), err))
sys.exit(1)
def printNoPrefix(self, info):
print("\033[1;36m%s\033[0m" % (info))
def printfNoPrefix(self, info):
printf("\033[1;36m%s\033[0m" % (info))
tdLog = TDLog()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册