log.py 1.3 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
###################################################################
#           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


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

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

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

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

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

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

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

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


tdLog = TDLog()