logging-ext2 0.2.3__py3-none-any.whl → 0.2.5__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.3"
4
+ __version__ = "0.2.5"
logging_ext2/handlers.py CHANGED
@@ -58,6 +58,7 @@ class TimedRotatingFileHandler(Handler):
58
58
  def do_rollover(self):
59
59
  if self.filepath.exists():
60
60
  self.stream.close()
61
+ self.stream = self.init_stream()
61
62
  paths: List[Path] = [
62
63
  i
63
64
  for i in self.base_dir.iterdir()
@@ -66,10 +67,14 @@ class TimedRotatingFileHandler(Handler):
66
67
  paths.sort(key=lambda x: x.name, reverse=True)
67
68
  to_delete: Path
68
69
  for to_delete in paths[self.max_keep:]:
70
+ if to_delete == self.filepath:
71
+ continue
69
72
  to_delete.unlink(missing_ok=True)
70
73
  for to_gzip_path in paths[self.flat_keep:self.max_keep]:
71
74
  # here use the system gzip command to ignore exceptions like
72
75
  # permission denied or file not found
76
+ if to_gzip_path == self.filepath:
77
+ continue
73
78
  try:
74
79
  if not to_gzip_path.stat().st_size:
75
80
  to_gzip_path.unlink(missing_ok=True)
@@ -78,7 +83,7 @@ class TimedRotatingFileHandler(Handler):
78
83
  continue
79
84
  if to_gzip_path.suffix == ".gz":
80
85
  continue
81
- lock_path = self.base_dir.joinpath(self.filename)
86
+ lock_path = self.base_dir.joinpath(".lock." + self.filename)
82
87
  lock_path.touch()
83
88
  with FileLock(lock_path, timeout=10):
84
89
  target_file = to_gzip_path.parent.joinpath(
@@ -90,4 +95,3 @@ class TimedRotatingFileHandler(Handler):
90
95
  ).with_suffix(".gz"))
91
96
  cmds = ["gzip", to_gzip_path]
92
97
  subprocess.run(cmds)
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
3
+ Version: 0.2.5
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
@@ -0,0 +1,8 @@
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,,
@@ -1,8 +0,0 @@
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,,