#!/usr/bin/python # -*- coding: utf-8 -*- from . import StringFormat import sys import platform platformName = platform.system() if platformName == 'Linux': from .Linux import LinuxCMDColorPrint PrintTool = LinuxCMDColorPrint.LinuxCMDColorPrint() elif platformName == 'Windows': from .Windows import WindowsCMDColorPrint PrintTool = WindowsCMDColorPrint.WindowsCMDColorPrint() elif platformName == 'Darwin': from .Linux import LinuxCMDColorPrint PrintTool = LinuxCMDColorPrint.LinuxCMDColorPrint() else: PrintTool = None def Log(content, noTag=True): """ 打印信息,需要格式化的String,请使用LogFormat """ if noTag: content = StringFormat.FormatStdoutString( str(content)) else: content = StringFormat.FormatStdoutString( str("Debug : %s" % content)) print(content) def LogSuccess(content, noTag=True): """ 打印警告信息 """ if noTag: content = StringFormat.FormatStdoutString( str(content)) else: content = StringFormat.FormatStdoutString( str("Debug : %s" % content)) if PrintTool: PrintTool.printGreen(content) else: print(content) def LogWaring(content, noTag=False): """ 打印警告信息 """ if noTag: content = StringFormat.FormatStdoutString( str(content)) else: content = StringFormat.FormatStdoutString( str("Waring : %s" % content)) if PrintTool: PrintTool.printYellow(content) else: print(content) def LogError(content, noTag=False): """ 打印错误信息 """ if noTag: content = StringFormat.FormatStdoutString( str(content)) else: content = StringFormat.FormatStdoutString( str("Error : %s" % content)) if PrintTool: PrintTool.printRed(content) else: print(content) def LogException(content, noTag=False): """ 打印错误信息 """ if noTag: content = StringFormat.FormatStdoutString( str(content)) else: content = StringFormat.FormatStdoutString( str("Exception : %s" % content)) if PrintTool: PrintTool.printRed(content) else: print(content)