From 68341449fb7b175c4af9707036802e8e05a16bec Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期三, 16 八月 2023 10:36:17 +0800 Subject: [PATCH] ++++++++++++++++ bug修复- --- log_module/log.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 49 insertions(+), 11 deletions(-) diff --git a/log_module/log.py b/log_module/log.py index 41f1d65..6956c3b 100644 --- a/log_module/log.py +++ b/log_module/log.py @@ -1,8 +1,6 @@ """ 鏃ュ織 """ -import logging -import os import sys from loguru import logger import constant @@ -104,8 +102,8 @@ filter=lambda record: record["extra"].get("name") == "code_operate", rotation="00:00", compression="zip", enqueue=True) # 鏄剧ず鍦ㄦ帶鍒跺彴 - logger.add(sys.stdout, - filter=lambda record: record["extra"].get("name") == "code_operate", enqueue=True) + # logger.add(sys.stdout, + # filter=lambda record: record["extra"].get("name") == "code_operate", enqueue=True) logger.add(self.get_path("device", "device"), filter=lambda record: record["extra"].get("name") == "device", rotation="00:00", compression="zip", enqueue=True) @@ -204,13 +202,40 @@ filter=lambda record: record["extra"].get("name") == "hx_trade_loop", rotation="00:00", compression="zip", enqueue=True) + logger.add(self.get_local_huaxin_path("l2", "transaction"), + filter=lambda record: record["extra"].get("name") == "local_huaxin_transaction", + rotation="00:00", compression="zip", enqueue=True) + logger.add(self.get_local_huaxin_path("l2", "orderdetail"), + filter=lambda record: record["extra"].get("name") == "local_huaxin_orderdetail", + rotation="00:00", compression="zip", enqueue=True) + logger.add(self.get_local_huaxin_path("l2", "upload"), + filter=lambda record: record["extra"].get("name") == "local_huaxin_upload", + rotation="00:00", compression="zip", enqueue=True) + logger.add(self.get_local_huaxin_path("l2", "subscript"), + filter=lambda record: record["extra"].get("name") == "local_huaxin_subscript", + rotation="00:00", compression="zip", enqueue=True) + logger.add(self.get_local_huaxin_path("contact", "debug"), + filter=lambda record: record["extra"].get("name") == "local_huaxin_debug", + rotation="00:00", compression="zip", enqueue=True) + + logger.add(self.get_local_huaxin_path("trade", "trade_debug"), + filter=lambda record: record["extra"].get("name") == "local_huaxin_trade_debug", + rotation="00:00", compression="zip", enqueue=True) + def get_path(self, dir_name, log_name): path_str = "{}/logs/gp/{}/{}".format(constant.get_path_prefix(), dir_name, log_name) + ".{time:YYYY-MM-DD}.log" # print(path_str) return path_str def get_hx_path(self, dir_name, log_name): - path_str = "{}/logs/huaxin/{}/{}".format(constant.get_path_prefix(), dir_name, log_name) + ".{time:YYYY-MM-DD}.log" + path_str = "{}/logs/huaxin/{}/{}".format(constant.get_path_prefix(), dir_name, + log_name) + ".{time:YYYY-MM-DD}.log" + # print(path_str) + return path_str + + def get_local_huaxin_path(self, dir_name, log_name): + path_str = "{}/logs/huaxin_local/{}/{}".format(constant.get_path_prefix(), dir_name, + log_name) + ".{time:YYYY-MM-DD}.log" # print(path_str) return path_str @@ -291,11 +316,24 @@ hx_logger_trade_debug = __mylogger.get_logger("hx_trade_debug") hx_logger_trade_loop = __mylogger.get_logger("hx_trade_loop") +# -------------------------------鍗庨懌鏈湴鏃ュ織--------------------------------- +logger_local_huaxin_l2_transaction = __mylogger.get_logger("local_huaxin_transaction") +logger_local_huaxin_l2_orderdetail = __mylogger.get_logger("local_huaxin_orderdetail") +logger_local_huaxin_l2_upload = __mylogger.get_logger("local_huaxin_upload") +logger_local_huaxin_l2_error = __mylogger.get_logger("local_huaxin_error") +logger_local_huaxin_l2_subscript = __mylogger.get_logger("local_huaxin_subscript") +logger_local_huaxin_contact_debug = __mylogger.get_logger("local_huaxin_debug") +logger_local_huaxin_trade_debug = __mylogger.get_logger("local_huaxin_trade_debug") + def close_print(): - if True: - return - logging.basicConfig(level=logging.ERROR) - if not constant.is_windows(): - os.close(1) - os.open('/dev/null', os.O_WRONLY) + pass + # logging.basicConfig(level=logging.ERROR) + # if not constant.is_windows(): + # os.close(1) + # os.open('/dev/null', os.O_WRONLY) + + +if __name__ == "__main__": + logger_l2_trade.info("娴嬭瘯") + input() -- Gitblit v1.8.0