log.py 1.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
###################################################################
#           Copyright (c) 2016 by TAOS Technologies, Inc.
#                     All rights reserved.
#
#  This file is proprietary and confidential to TAOS Technologies.
#  No part of this file may be reproduced, stored, transmitted,
#  disclosed or used in any form or by any means other than as
#  expressly provided by the written permission from Jianhui Tao
#
###################################################################

# -*- coding: utf-8 -*-

import sys
import os
import time
import datetime
from distutils.log import warn as printf


class TDLog:
    def __init__(self):
        self.path = ""

    def info(self, info):
        print("%s %s\n" % (datetime.datetime.now(), info))

    def sleep(self, sec):
        print("%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))

    def success(self, info):
S
Shengliang Guan 已提交
36
        print("\033[1;32m%s %s\033[0m" % (datetime.datetime.now(), info))
37 38

    def notice(self, err):
S
Shengliang Guan 已提交
39
        print("\033[1;33m%s %s\033[0m" % (datetime.datetime.now(), err))
40 41

    def exit(self, err):
S
Shengliang Guan 已提交
42
        print("\033[1;31m%s %s\033[0m" % (datetime.datetime.now(), err))
43 44 45 46 47 48 49
        sys.exit(1)

    def printNoPrefix(self, info):
        print("\033[1;36m%s\033[0m" % (info))


tdLog = TDLog()