使用中文日志 调整一些业务逻辑

This commit is contained in:
2024-10-08 23:57:56 +08:00
parent dd9b110adb
commit 3d92652201
6 changed files with 77 additions and 75 deletions

View File

@@ -8,6 +8,8 @@ import time
import prot_codec as pc
import target as tg
from log import myprint
from log import log_init
@@ -15,22 +17,6 @@ import target as tg
SERVER_PORT = 5345
_log_fp=None
def _time():
return '['+time.strftime("%Y-%m-%d %H:%M:%S")+']'
def myprint_dec(func):
def wrapper(*args, **kwargs):
# 在这里添加额外的功能
# print(_time(), str(e),file=_log_fp)
kwargs["file"]=_log_fp
result = func(_time(),*args, **kwargs)
_log_fp.flush()
return result
return wrapper
myprint=myprint_dec(print)
@@ -79,5 +65,5 @@ def start_service():
if __name__ == "__main__":
_log_fp=open("proxy_server.log",mode="w+",encoding="utf-8")
log_init("proxy_service.log")
start_service()