logging-ext2 0.2.2__tar.gz → 0.2.4__tar.gz
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-0.2.2 → logging_ext2-0.2.4}/PKG-INFO +2 -1
- {logging_ext2-0.2.2 → logging_ext2-0.2.4}/pyproject.toml +1 -1
- {logging_ext2-0.2.2 → logging_ext2-0.2.4}/src/logging_ext2/__about__.py +1 -1
- {logging_ext2-0.2.2 → logging_ext2-0.2.4}/src/logging_ext2/handlers.py +15 -7
- {logging_ext2-0.2.2 → logging_ext2-0.2.4}/tests/__init__.py +2 -2
- logging_ext2-0.2.2/.git +0 -1
- {logging_ext2-0.2.2 → logging_ext2-0.2.4}/.gitignore +0 -0
- {logging_ext2-0.2.2 → logging_ext2-0.2.4}/LICENSE +0 -0
- {logging_ext2-0.2.2 → logging_ext2-0.2.4}/README.md +0 -0
- {logging_ext2-0.2.2 → logging_ext2-0.2.4}/src/logging_ext2/__init__.py +0 -0
- {logging_ext2-0.2.2 → logging_ext2-0.2.4}/src/logging_ext2/types.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: logging-ext2
|
3
|
-
Version: 0.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
|
@@ -24,7 +24,7 @@ classifiers = [
|
|
24
24
|
"Programming Language :: Python :: Implementation :: CPython",
|
25
25
|
"Programming Language :: Python :: Implementation :: PyPy",
|
26
26
|
]
|
27
|
-
dependencies = []
|
27
|
+
dependencies = ["filelock"]
|
28
28
|
|
29
29
|
[project.urls]
|
30
30
|
Documentation = "https://github.com/ramwin/logging-ext#readme"
|
@@ -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)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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()
|
@@ -15,7 +15,7 @@ class Test(unittest.TestCase):
|
|
15
15
|
handlera = TimedRotatingFileHandler(
|
16
16
|
filename="tests/info.log",
|
17
17
|
datetime_formatter="%Y-%m-%d_%H:%M:%S",
|
18
|
-
max_keep=
|
18
|
+
max_keep=20, flat_keep=2)
|
19
19
|
loggera.addHandler(logging.StreamHandler())
|
20
20
|
loggera.addHandler(handlera)
|
21
21
|
loggera.setLevel(logging.INFO)
|
@@ -25,7 +25,7 @@ class Test(unittest.TestCase):
|
|
25
25
|
loggerb.addHandler(TimedRotatingFileHandler(
|
26
26
|
filename="tests/info.log",
|
27
27
|
datetime_formatter="%Y-%m-%d_%H:%M:%S",
|
28
|
-
max_keep=
|
28
|
+
max_keep=20, flat_keep=2))
|
29
29
|
loggerb.addHandler(logging.StreamHandler())
|
30
30
|
loggerb.setLevel(logging.INFO)
|
31
31
|
|
logging_ext2-0.2.2/.git
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
gitdir: ../../.git/modules/python/logging-ext2
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|