123456789101112131415161718192021222324252627282930313233343536 |
- # coding=utf-8
- """ 日志工具类 """
- import sys
- class Logging(object):
- """ 日志工具 """
- RED = '\033[31m'
- GREEN = '\033[32m'
- YELLOW = '\033[33m'
- MAGENTA = '\033[35m'
- RESET = '\033[0m'
- @staticmethod
- def __print(s, color=None):
- if color and sys.stdout.isatty() and sys.platform != 'win32':
- print color + s + Logging.RESET
- else:
- print s
- @staticmethod
- def debug(s):
- Logging.__print("Debug: " + s, Logging.MAGENTA)
- @staticmethod
- def info(s):
- Logging.__print("Info: " + s, Logging.GREEN)
- @staticmethod
- def warning(s):
- Logging.__print("Warning: " + s, Logging.YELLOW)
- @staticmethod
- def error(s):
- Logging.__print("Error: " + s, Logging.RED)
|