logging-ext2 0.2.1__py3-none-any.whl → 0.2.3__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 +1 -1
- logging_ext2/handlers.py +20 -9
- {logging_ext2-0.2.1.dist-info → logging_ext2-0.2.3.dist-info}/METADATA +2 -1
- logging_ext2-0.2.3.dist-info/RECORD +8 -0
- logging_ext2-0.2.1.dist-info/RECORD +0 -8
- {logging_ext2-0.2.1.dist-info → logging_ext2-0.2.3.dist-info}/WHEEL +0 -0
- {logging_ext2-0.2.1.dist-info → logging_ext2-0.2.3.dist-info}/licenses/LICENSE +0 -0
logging_ext2/__about__.py
CHANGED
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
|
@@ -67,16 +70,24 @@ class TimedRotatingFileHandler(Handler):
|
|
67
70
|
for to_gzip_path in paths[self.flat_keep:self.max_keep]:
|
68
71
|
# here use the system gzip command to ignore exceptions like
|
69
72
|
# permission denied or file not found
|
70
|
-
|
71
|
-
to_gzip_path.
|
73
|
+
try:
|
74
|
+
if not to_gzip_path.stat().st_size:
|
75
|
+
to_gzip_path.unlink(missing_ok=True)
|
76
|
+
continue
|
77
|
+
except FileNotFoundError:
|
72
78
|
continue
|
73
79
|
if to_gzip_path.suffix == ".gz":
|
74
80
|
continue
|
75
|
-
self.base_dir.joinpath(self.filename)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
81
|
+
lock_path = self.base_dir.joinpath(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)
|
82
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.
|
3
|
+
Version: 0.2.3
|
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=2TvUlJ3rS9OmT2VeHP6SC0RFt1TGcxGLTqiDuXb_omA,121
|
2
|
+
logging_ext2/__init__.py,sha256=BA6rgdmh3z2v01cbHU1FRMsBIRV5vQjh2w9FzG2F2GY,99
|
3
|
+
logging_ext2/handlers.py,sha256=Rv6ygtxuDkM7shucJPMBjmTQhTFNzGwUM8ZrVQXR_YY,3290
|
4
|
+
logging_ext2/types.py,sha256=cLjODjTgxrZEXUZzOkrFm3s6bUG3Itc_fS7KJ-MSWC8,237
|
5
|
+
logging_ext2-0.2.3.dist-info/METADATA,sha256=XUsJSKKkMlyo6rZ4ayMEg9CkoiOPPEHkr-CYsh_aUls,1453
|
6
|
+
logging_ext2-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
+
logging_ext2-0.2.3.dist-info/licenses/LICENSE,sha256=RckqF9bdq7oO9RrL4iZYuXNhkIcXexbXNF2ToiaJymU,1067
|
8
|
+
logging_ext2-0.2.3.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
logging_ext2/__about__.py,sha256=mUu4qhx9EBxDtNiujiI_vqVwo8Jx3o3ULeBVbvx8RkM,121
|
2
|
-
logging_ext2/__init__.py,sha256=BA6rgdmh3z2v01cbHU1FRMsBIRV5vQjh2w9FzG2F2GY,99
|
3
|
-
logging_ext2/handlers.py,sha256=UCPKGYrOAFT5Eztv4UJa1ZMlbecjn4nqNg02jxbJXlA,2875
|
4
|
-
logging_ext2/types.py,sha256=cLjODjTgxrZEXUZzOkrFm3s6bUG3Itc_fS7KJ-MSWC8,237
|
5
|
-
logging_ext2-0.2.1.dist-info/METADATA,sha256=TIMXq6mEkBHRUvXlE7kek02kcv7YcYxWgubJUQ2oLKs,1429
|
6
|
-
logging_ext2-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
-
logging_ext2-0.2.1.dist-info/licenses/LICENSE,sha256=RckqF9bdq7oO9RrL4iZYuXNhkIcXexbXNF2ToiaJymU,1067
|
8
|
-
logging_ext2-0.2.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|