log.py 1.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
###################################################################
#           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
18
from distutils.log import warn as printf
19 20 21 22 23 24 25


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

    def info(self, info):
26
        print("%s %s" % (datetime.datetime.now(), info))
27 28

    def sleep(self, sec):
29
        print("%s sleep %d seconds" % (datetime.datetime.now(), sec))
30 31 32
        time.sleep(sec)

    def debug(self, err):
33
        print("\033[1;36m%s %s\033[0m" % (datetime.datetime.now(), err))
34 35

    def success(self, info):
36
        printf("\033[1;32m%s %s\033[0m" % (datetime.datetime.now(), info))
37 38

    def notice(self, err):
39
        printf("\033[1;33m%s %s\033[0m" % (datetime.datetime.now(), err))
40 41

    def exit(self, err):
42
        printf("\033[1;31m%s %s\033[0m" % (datetime.datetime.now(), err))
43 44
        sys.exit(1)

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


tdLog = TDLog()