xenoslib 0.3.0__tar.gz → 0.3.2__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.
- {xenoslib-0.3.0/xenoslib.egg-info → xenoslib-0.3.2}/PKG-INFO +1 -1
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/about.py +1 -1
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/base.py +14 -37
- {xenoslib-0.3.0 → xenoslib-0.3.2/xenoslib.egg-info}/PKG-INFO +1 -1
- {xenoslib-0.3.0 → xenoslib-0.3.2}/LICENSE +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/README.md +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/setup.cfg +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/setup.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/__init__.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/__main__.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/dev.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/extend.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/linux.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/mail.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/mock.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/onedrive.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/tools/__init__.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/tools/config_loader.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/win_trayicon.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib/windows.py +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib.egg-info/SOURCES.txt +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib.egg-info/dependency_links.txt +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib.egg-info/requires.txt +0 -0
- {xenoslib-0.3.0 → xenoslib-0.3.2}/xenoslib.egg-info/top_level.txt +0 -0
|
@@ -11,8 +11,7 @@ from logging.handlers import TimedRotatingFileHandler
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def init_logger(
|
|
14
|
-
use_file: bool =
|
|
15
|
-
level: int = logging.INFO,
|
|
14
|
+
use_file: bool = False,
|
|
16
15
|
backup_count: int = 0, # New parameter: number of log files to retain (0 means keep all)
|
|
17
16
|
) -> logging.Logger:
|
|
18
17
|
"""
|
|
@@ -20,40 +19,27 @@ def init_logger(
|
|
|
20
19
|
|
|
21
20
|
Args:
|
|
22
21
|
use_file: Whether to enable file logging
|
|
23
|
-
level: Logging level (DEBUG/INFO/WARN/ERROR)
|
|
24
22
|
backup_count: Number of historical log files to retain (default 0=keep all)
|
|
25
23
|
"""
|
|
26
|
-
# 1. Dynamically get caller's filename
|
|
27
|
-
caller_frame = inspect.stack()[1]
|
|
28
|
-
caller_path = caller_frame.filename
|
|
29
|
-
caller_name = os.path.splitext(os.path.basename(caller_path))[0]
|
|
30
|
-
|
|
31
|
-
# 2. Configure log directory and filename
|
|
32
|
-
log_dir = "logs"
|
|
33
|
-
os.makedirs(log_dir, exist_ok=True)
|
|
34
|
-
log_filename = f"{caller_name}.log"
|
|
35
|
-
full_path = os.path.join(log_dir, log_filename)
|
|
36
|
-
|
|
37
|
-
# 3. Avoid duplicate initialization
|
|
38
|
-
logger = logging.getLogger(caller_name)
|
|
39
|
-
if logger.hasHandlers():
|
|
40
|
-
return logger
|
|
41
|
-
|
|
42
|
-
logger.setLevel(level)
|
|
43
24
|
formatter = logging.Formatter(
|
|
44
|
-
"%(asctime)s
|
|
25
|
+
"%(asctime)s %(filename)s %(levelname)s [line:%(lineno)d] %(message)s",
|
|
45
26
|
datefmt="%Y-%m-%d %H:%M:%S",
|
|
46
27
|
)
|
|
47
|
-
|
|
48
|
-
# 4. Console handler (required)
|
|
49
28
|
console_handler = logging.StreamHandler()
|
|
50
29
|
console_handler.setFormatter(formatter)
|
|
51
30
|
handlers = [console_handler]
|
|
52
31
|
|
|
53
|
-
#
|
|
32
|
+
# File handler (daily rotation + file retention policy)
|
|
54
33
|
if use_file:
|
|
34
|
+
# Dynamically get caller's filename
|
|
35
|
+
caller_frame = inspect.stack()[1]
|
|
36
|
+
caller_path = caller_frame.filename
|
|
37
|
+
caller_name = os.path.splitext(caller_path)[0]
|
|
38
|
+
# Configure log directory and filename
|
|
39
|
+
log_filename = f"{caller_name}.log"
|
|
40
|
+
|
|
55
41
|
file_handler = TimedRotatingFileHandler(
|
|
56
|
-
|
|
42
|
+
log_filename,
|
|
57
43
|
when="midnight", # Rotate daily
|
|
58
44
|
interval=1,
|
|
59
45
|
backupCount=backup_count, # Key parameter: controls number of retained files
|
|
@@ -62,10 +48,7 @@ def init_logger(
|
|
|
62
48
|
file_handler.setFormatter(formatter)
|
|
63
49
|
handlers.append(file_handler)
|
|
64
50
|
|
|
65
|
-
|
|
66
|
-
logger.addHandler(handler)
|
|
67
|
-
|
|
68
|
-
return logger
|
|
51
|
+
logging.basicConfig(level=logging.INFO, handlers=handlers)
|
|
69
52
|
|
|
70
53
|
|
|
71
54
|
def sleep(seconds, mute=False):
|
|
@@ -414,12 +397,6 @@ def get_attr_val(obj, *args):
|
|
|
414
397
|
|
|
415
398
|
|
|
416
399
|
if __name__ == "__main__":
|
|
417
|
-
data = {"a": 1, "b": {"c": 2, "d": [3, 4, {"e": 5}]}, "f": (6, 7, {"g": 8})}
|
|
418
|
-
n = NestedData(data)
|
|
419
|
-
|
|
420
|
-
from pprint import pprint
|
|
421
400
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
# n.show_result()
|
|
425
|
-
# pprint(list(n.find(lambda k, v: "i" in v, ignore_exc=True)))
|
|
401
|
+
init_logger()
|
|
402
|
+
logging.info("test")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|