串口消息通过颜色区分
This commit is contained in:
@@ -5,6 +5,11 @@ import sys
|
||||
# 同一个进程中所有调用这个文件的 .py 文件都使用这个变量
|
||||
_log_fp=None
|
||||
|
||||
STR_RED="\033[0;31m"
|
||||
STR_BLUE="\033[0;34m"
|
||||
STR_YELLOW="\033[0;33m"
|
||||
STR_END="\033[0m"
|
||||
|
||||
def _time():
|
||||
return '['+time.strftime("%Y-%m-%d %H:%M:%S")+']'
|
||||
|
||||
@@ -30,7 +35,7 @@ def mywrite(data:str):
|
||||
txt=txt.replace('\n\n','\n')
|
||||
_log_fp.write(txt)
|
||||
_log_fp.flush()
|
||||
sys.stdout.write(data)
|
||||
sys.stdout.write(f"{STR_YELLOW}{data}{STR_END}")
|
||||
sys.stdout.flush()
|
||||
|
||||
def log_init(file_name:str):
|
||||
|
Reference in New Issue
Block a user