上传flash镜像并转化为txt
This commit is contained in:
27
log.py
Normal file
27
log.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import time
|
||||
|
||||
|
||||
|
||||
# 同一个进程中所有调用这个文件的 .py 文件都使用这个变量
|
||||
_log_fp=None
|
||||
|
||||
def _time():
|
||||
return '['+time.strftime("%Y-%m-%d %H:%M:%S")+']'
|
||||
|
||||
def myprint_dec(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
# 在这里添加额外的功能
|
||||
print(*args, **kwargs)
|
||||
kwargs["file"]=_log_fp
|
||||
result = func(*args, **kwargs)
|
||||
_log_fp.flush()
|
||||
return result
|
||||
return wrapper
|
||||
|
||||
myprint=myprint_dec(print)
|
||||
|
||||
def log_init(file_name:str):
|
||||
global _log_fp
|
||||
if _log_fp is None:
|
||||
_log_fp=open(file_name,mode="w+",encoding="utf-8")
|
||||
|
||||
Reference in New Issue
Block a user