logging-ext2 0.2.5__py3-none-any.whl → 0.3.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.
- logging_ext2/__about__.py +1 -1
- logging_ext2/handlers.py +10 -3
- {logging_ext2-0.2.5.dist-info → logging_ext2-0.3.0.dist-info}/METADATA +1 -1
- logging_ext2-0.3.0.dist-info/RECORD +8 -0
- logging_ext2-0.2.5.dist-info/RECORD +0 -8
- {logging_ext2-0.2.5.dist-info → logging_ext2-0.3.0.dist-info}/WHEEL +0 -0
- {logging_ext2-0.2.5.dist-info → logging_ext2-0.3.0.dist-info}/licenses/LICENSE +0 -0
logging_ext2/__about__.py
CHANGED
logging_ext2/handlers.py
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
import datetime
|
7
7
|
import subprocess
|
8
8
|
import time
|
9
|
+
from typing import List
|
9
10
|
|
10
11
|
from filelock import FileLock
|
11
12
|
|
@@ -21,18 +22,19 @@ class TimedRotatingFileHandler(Handler):
|
|
21
22
|
"""
|
22
23
|
|
23
24
|
def __init__(self, level=NOTSET, filename="log.log",
|
24
|
-
datetime_formatter="%Y-%m-%d", max_keep=10, flat_keep=2):
|
25
|
+
datetime_formatter="%Y-%m-%d", max_keep=10, flat_keep=2) -> None:
|
25
26
|
"""
|
26
27
|
params:
|
27
28
|
max_keep: how many files will the rotation keep
|
28
29
|
flat_keep: how many files will stay in text mod, the other (max_keep-flat_keep) will be compressed using gzip
|
29
30
|
"""
|
30
|
-
self.filepath: Path = None
|
31
|
+
self.filepath: Path = None # type: ignore[assignment]
|
31
32
|
self.filename = Path(filename).name
|
32
33
|
self.base_dir = Path(filename).parent
|
33
34
|
self.datetime_formatter = datetime_formatter
|
34
35
|
self.current_time_str = self.get_time_str()
|
35
36
|
self.stream = self.init_stream()
|
37
|
+
assert self.filepath
|
36
38
|
self.max_keep = max_keep
|
37
39
|
self.flat_keep = flat_keep
|
38
40
|
super().__init__(level)
|
@@ -55,7 +57,7 @@ class TimedRotatingFileHandler(Handler):
|
|
55
57
|
new_time_str = self.get_time_str()
|
56
58
|
return new_time_str != self.current_time_str
|
57
59
|
|
58
|
-
def do_rollover(self):
|
60
|
+
def do_rollover(self) -> None:
|
59
61
|
if self.filepath.exists():
|
60
62
|
self.stream.close()
|
61
63
|
self.stream = self.init_stream()
|
@@ -70,6 +72,11 @@ class TimedRotatingFileHandler(Handler):
|
|
70
72
|
if to_delete == self.filepath:
|
71
73
|
continue
|
72
74
|
to_delete.unlink(missing_ok=True)
|
75
|
+
|
76
|
+
def gzip_file(self, paths) -> None:
|
77
|
+
"""
|
78
|
+
TODO use async function to gzip file
|
79
|
+
"""
|
73
80
|
for to_gzip_path in paths[self.flat_keep:self.max_keep]:
|
74
81
|
# here use the system gzip command to ignore exceptions like
|
75
82
|
# permission denied or file not found
|
@@ -0,0 +1,8 @@
|
|
1
|
+
logging_ext2/__about__.py,sha256=spWUlBPWMENSlVLrNMfRO_unWIWWKqZrmfbE2omj94M,121
|
2
|
+
logging_ext2/__init__.py,sha256=BA6rgdmh3z2v01cbHU1FRMsBIRV5vQjh2w9FzG2F2GY,99
|
3
|
+
logging_ext2/handlers.py,sha256=eIjll7VJHXTgsEk7Zs2Bs9UlXdsTtIOkCUC38oeydNI,3647
|
4
|
+
logging_ext2/types.py,sha256=cLjODjTgxrZEXUZzOkrFm3s6bUG3Itc_fS7KJ-MSWC8,237
|
5
|
+
logging_ext2-0.3.0.dist-info/METADATA,sha256=73KZwCVI3P-1ajyPUmBbasVGtCNPNk64DPNsj3wf0eU,1453
|
6
|
+
logging_ext2-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
+
logging_ext2-0.3.0.dist-info/licenses/LICENSE,sha256=RckqF9bdq7oO9RrL4iZYuXNhkIcXexbXNF2ToiaJymU,1067
|
8
|
+
logging_ext2-0.3.0.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
logging_ext2/__about__.py,sha256=5S33mBG07NClCl4iUi5Wy-ACpn1ukuHg74gcRj2V8IA,121
|
2
|
-
logging_ext2/__init__.py,sha256=BA6rgdmh3z2v01cbHU1FRMsBIRV5vQjh2w9FzG2F2GY,99
|
3
|
-
logging_ext2/handlers.py,sha256=LUL0qWoj0eTlBHlot0cMxIkQ4XTH1TFJcl3jsdLfMxs,3440
|
4
|
-
logging_ext2/types.py,sha256=cLjODjTgxrZEXUZzOkrFm3s6bUG3Itc_fS7KJ-MSWC8,237
|
5
|
-
logging_ext2-0.2.5.dist-info/METADATA,sha256=0egTE1kaQdRrMOmwNeW8_BSUBv0_KVUIBfQzEQy9IKA,1453
|
6
|
-
logging_ext2-0.2.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
-
logging_ext2-0.2.5.dist-info/licenses/LICENSE,sha256=RckqF9bdq7oO9RrL4iZYuXNhkIcXexbXNF2ToiaJymU,1067
|
8
|
-
logging_ext2-0.2.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|