def color_text_decorator(function):
def real_func(self, string):
windll.Kernel32.GetStdHandle.restype = c_ulong
h = windll.Kernel32.GetStdHandle(c_ulong(0xfffffff5))
if function.__name__.upper() == 'ERROR':
windll.Kernel32.SetConsoleTextAttribute(h, 12)
elif function.__name__.upper() == 'WARN':
windll.Kernel32.SetConsoleTextAttribute(h, 13)
elif function.__name__.upper() == 'INFO':
windll.Kernel32.SetConsoleTextAttribute(h, 14)
elif function.__name__.upper() == 'DEBUG':
windll.Kernel32.SetConsoleTextAttribute(h, 15)
else:
windll.Kernel32.SetConsoleTextAttribute(h, 15)
function(self, string)
windll.Kernel32.SetConsoleTextAttribute(h, 15)
return real_func
评论列表
文章目录