logging-ext2 0.2.2__py3-none-any.whl → 0.2.4__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.
logging_ext2/__about__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2025-present Xiang Wang <ramwin@qq.com>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.2.2"
4
+ __version__ = "0.2.4"
logging_ext2/handlers.py CHANGED
@@ -5,6 +5,9 @@
5
5
 
6
6
  import datetime
7
7
  import subprocess
8
+ import time
9
+
10
+ from filelock import FileLock
8
11
 
9
12
  from logging import Handler, NOTSET
10
13
  from pathlib import Path
@@ -75,11 +78,16 @@ class TimedRotatingFileHandler(Handler):
75
78
  continue
76
79
  if to_gzip_path.suffix == ".gz":
77
80
  continue
78
- self.base_dir.joinpath(self.filename).touch()
79
- cmds = ["flock",
80
- "--nonblock",
81
- self.base_dir.joinpath(self.filename),
82
- "--command",
83
- f"gzip {to_gzip_path}"]
84
- subprocess.run(cmds)
81
+ lock_path = self.base_dir.joinpath(".lock." + self.filename)
82
+ lock_path.touch()
83
+ with FileLock(lock_path, timeout=10):
84
+ target_file = to_gzip_path.parent.joinpath(
85
+ to_gzip_path.name + ".gz"
86
+ )
87
+ if target_file.exists():
88
+ target_file.rename(target_file.parent.joinpath(
89
+ target_file.stem + "_" + str(time.time())
90
+ ).with_suffix(".gz"))
91
+ cmds = ["gzip", to_gzip_path]
92
+ subprocess.run(cmds)
85
93
  self.stream = self.init_stream()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: logging-ext2
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: extend python logging library
5
5
  Project-URL: Documentation, https://github.com/ramwin/logging-ext#readme
6
6
  Project-URL: Issues, https://github.com/ramwin/logging-ext/issues
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: Implementation :: CPython
19
19
  Classifier: Programming Language :: Python :: Implementation :: PyPy
20
20
  Requires-Python: >=3.8
21
+ Requires-Dist: filelock
21
22
  Description-Content-Type: text/markdown
22
23
 
23
24
  # logging-ext2
@@ -0,0 +1,8 @@
1
+ logging_ext2/__about__.py,sha256=-MvhEn10ANMYbo0dJNnemdwJcdTb5ZdoQzP842QKWd4,121
2
+ logging_ext2/__init__.py,sha256=BA6rgdmh3z2v01cbHU1FRMsBIRV5vQjh2w9FzG2F2GY,99
3
+ logging_ext2/handlers.py,sha256=xaeeJKt8mNV404XZFSImaKQie_eg0FSL-21eFnqDJ5c,3301
4
+ logging_ext2/types.py,sha256=cLjODjTgxrZEXUZzOkrFm3s6bUG3Itc_fS7KJ-MSWC8,237
5
+ logging_ext2-0.2.4.dist-info/METADATA,sha256=SdPhAGWpX7cGVp_D39Euh_ECEWR6eiQnmiH_rarABLk,1453
6
+ logging_ext2-0.2.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ logging_ext2-0.2.4.dist-info/licenses/LICENSE,sha256=RckqF9bdq7oO9RrL4iZYuXNhkIcXexbXNF2ToiaJymU,1067
8
+ logging_ext2-0.2.4.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- logging_ext2/__about__.py,sha256=CwnIpwy4dY5_pEu6b684l8Sx6zWLEmy0PSCcBVT27Zg,121
2
- logging_ext2/__init__.py,sha256=BA6rgdmh3z2v01cbHU1FRMsBIRV5vQjh2w9FzG2F2GY,99
3
- logging_ext2/handlers.py,sha256=_kD4jtd9otv5Me4Zx099Glh2wZoq1gJTGt7HiQAE7y0,2967
4
- logging_ext2/types.py,sha256=cLjODjTgxrZEXUZzOkrFm3s6bUG3Itc_fS7KJ-MSWC8,237
5
- logging_ext2-0.2.2.dist-info/METADATA,sha256=T6ZjAFvVK4N8PnNACvYnAIm9RabCziS4ZBIj7IEmUwc,1429
6
- logging_ext2-0.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- logging_ext2-0.2.2.dist-info/licenses/LICENSE,sha256=RckqF9bdq7oO9RrL4iZYuXNhkIcXexbXNF2ToiaJymU,1067
8
- logging_ext2-0.2.2.dist-info/RECORD,,