logging-ext2 0.2.5__tar.gz → 0.3.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: logging-ext2
3
- Version: 0.2.5
3
+ Version: 0.3.0
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
@@ -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.5"
4
+ __version__ = "0.3.0"
@@ -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
File without changes
File without changes
File without changes