xtn-tools-pro 1.0.1.1.9__py3-none-any.whl → 1.0.1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xtn_tools_pro/utils/log.py +17 -3
- {xtn_tools_pro-1.0.1.1.9.dist-info → xtn_tools_pro-1.0.1.2.0.dist-info}/METADATA +1 -1
- {xtn_tools_pro-1.0.1.1.9.dist-info → xtn_tools_pro-1.0.1.2.0.dist-info}/RECORD +7 -7
- {xtn_tools_pro-1.0.1.1.9.dist-info → xtn_tools_pro-1.0.1.2.0.dist-info}/LICENSE +0 -0
- {xtn_tools_pro-1.0.1.1.9.dist-info → xtn_tools_pro-1.0.1.2.0.dist-info}/WHEEL +0 -0
- {xtn_tools_pro-1.0.1.1.9.dist-info → xtn_tools_pro-1.0.1.2.0.dist-info}/entry_points.txt +0 -0
- {xtn_tools_pro-1.0.1.1.9.dist-info → xtn_tools_pro-1.0.1.2.0.dist-info}/top_level.txt +0 -0
xtn_tools_pro/utils/log.py
CHANGED
@@ -72,6 +72,17 @@ class BoldFormatter(logging.Formatter):
|
|
72
72
|
return "\033[1m" + result + "\033[0m"
|
73
73
|
|
74
74
|
|
75
|
+
def get_caller_script_path():
|
76
|
+
# 获取调用栈列表
|
77
|
+
stack = inspect.stack()
|
78
|
+
# 遍历调用栈,找到第一个非本模块的调用者
|
79
|
+
for frame_info in stack:
|
80
|
+
filename = frame_info.filename
|
81
|
+
if filename != __file__: # 排除日志模块自身的路径
|
82
|
+
return os.path.abspath(filename)
|
83
|
+
return os.path.abspath(__file__) # 默认返回当前模块路径(理论上不会执行到这里)
|
84
|
+
|
85
|
+
|
75
86
|
class Log:
|
76
87
|
def __init__(self, name, path=None, log_level='DEBUG',
|
77
88
|
is_write_to_console=True,
|
@@ -102,13 +113,16 @@ class Log:
|
|
102
113
|
self.logger.setLevel(log_level.upper())
|
103
114
|
self.save_time_log_path = save_time_log_path
|
104
115
|
if save_time_log_path:
|
116
|
+
# 获取调用文件的所在文件夹路径
|
117
|
+
run_py_path = os.path.dirname(get_caller_script_path())
|
105
118
|
# 记录当前的日期,用于之后检查日期是否已经改变
|
106
119
|
self.current_date = get_time_timestamp_to_datestr(format="%Y_%m_%d")
|
107
120
|
# 记录日志文件的路径模板,用于之后创建新的日志文件
|
108
|
-
self.path_template =
|
121
|
+
self.path_template = f"logs/{{date}}/{name}.log"
|
109
122
|
path = self.path_template.format(date=self.current_date)
|
110
123
|
if is_write_to_file:
|
111
|
-
|
124
|
+
mkdirs_dir_log_path = os.path.join(run_py_path, path)
|
125
|
+
mkdirs_dir(mkdirs_dir_log_path)
|
112
126
|
|
113
127
|
# 创建日志格式化器
|
114
128
|
# formatter = logging.Formatter('[%(now_datestr)s] [%(levelname)s] [%(func_name)s] - %(message)s') # 原
|
@@ -229,4 +243,4 @@ if __name__ == '__main__':
|
|
229
243
|
logger.info("info level message")
|
230
244
|
logger.warning("warning level message")
|
231
245
|
logger.critical("critical level message 你好")
|
232
|
-
time.sleep(1)
|
246
|
+
# time.sleep(1)
|
@@ -56,15 +56,15 @@ xtn_tools_pro/utils/__init__.py,sha256=I1_n_NP23F2lBqlF4EOlnOdLYxM8M4pbn63UhJN1h
|
|
56
56
|
xtn_tools_pro/utils/crypto.py,sha256=fyqno82Tw8LeF5i8YiEpjPI3oswsqTeWE5Lc9M2ef68,4603
|
57
57
|
xtn_tools_pro/utils/file_utils.py,sha256=obaBP7CaBCsXxzqGeWzV2l0yw7vicgKOaXzmpMV8ips,2567
|
58
58
|
xtn_tools_pro/utils/helpers.py,sha256=0CTMY7wfSQR_DC9-v1lkKQLpWcB1FL9V_kw_5DOcZ40,4454
|
59
|
-
xtn_tools_pro/utils/log.py,sha256=
|
59
|
+
xtn_tools_pro/utils/log.py,sha256=V_NNFV6aFlQasj5Ejal2lo18EHWWCSOQiZf54j-Xhkg,10788
|
60
60
|
xtn_tools_pro/utils/retry.py,sha256=0wjHsR5DBBKpv4naMfxiky8kprrZes4WURIfFQ4H708,1657
|
61
61
|
xtn_tools_pro/utils/set_data.py,sha256=BzCLbEDO83csDHBey8kP7SoE6kx6EjqE7OqRBY7k82s,17608
|
62
62
|
xtn_tools_pro/utils/shell.py,sha256=s6sJedxLLQokcI1hF5YSD3qgGUPK0brNcP-D3-yv54I,3790
|
63
63
|
xtn_tools_pro/utils/sql.py,sha256=EAKzbkZP7Q09j15Gm6o0_uq0qgQmcCQT6EAawbpp4v0,6263
|
64
64
|
xtn_tools_pro/utils/time_utils.py,sha256=TUtzG61PeVYXhaQd6pBrXAdlz7tBispNIRQRcGhE2No,4859
|
65
|
-
xtn_tools_pro-1.0.1.
|
66
|
-
xtn_tools_pro-1.0.1.
|
67
|
-
xtn_tools_pro-1.0.1.
|
68
|
-
xtn_tools_pro-1.0.1.
|
69
|
-
xtn_tools_pro-1.0.1.
|
70
|
-
xtn_tools_pro-1.0.1.
|
65
|
+
xtn_tools_pro-1.0.1.2.0.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
66
|
+
xtn_tools_pro-1.0.1.2.0.dist-info/METADATA,sha256=Uq-pXRcnCK6soAPHfV2TX7om-AzcQeJQJ8EsLfKs-aY,545
|
67
|
+
xtn_tools_pro-1.0.1.2.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
68
|
+
xtn_tools_pro-1.0.1.2.0.dist-info/entry_points.txt,sha256=t8CtXWOgw7nRDW3XNlZh8MT_P4l8EzsFnyWi5b3ovrc,68
|
69
|
+
xtn_tools_pro-1.0.1.2.0.dist-info/top_level.txt,sha256=jyB3FLDEr8zE1U7wHczTgIbvUpALhR-ULF7RVEO7O2U,14
|
70
|
+
xtn_tools_pro-1.0.1.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|