VersaLog 2.5.4__tar.gz → 2.6.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.1
2
2
  Name: VersaLog
3
- Version: 2.5.4
3
+ Version: 2.6.0
4
4
  Summary: Versatile logging library.
5
5
  Home-page:
6
6
  Author:
@@ -17,6 +17,7 @@ Classifier: Operating System :: OS Independent
17
17
  Requires-Python: >=3.8, <3.14
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
+ Requires-Dist: plyer
20
21
 
21
22
  ## What is VersaLog.py?
22
23
 
@@ -27,8 +28,69 @@ License-File: LICENSE
27
28
  [![Discord](https://img.shields.io/badge/Discord-Support%20Server-7289DA?style=flat&logo=discord)](https://discord.gg/Ms2ejEES)
28
29
 
29
30
  What is VersaLog.py?
30
- VersaLog is a powerful and flexible logging library for Python.
31
- It supports everything from simple usage to advanced, highly customizable configurations to meet a wide range of needs.
31
+
32
+ VersaLog is a modern, powerful, and flexible logging library for Python.
33
+ It supports everything from simple usage to advanced, highly customizable configurations, making it suitable for a wide range of use cases.
34
+
35
+ ## Feature
36
+
37
+ ### Basic Logging
38
+
39
+ - Supports standard log levels:
40
+ - `INFO`, `ERROR`, `WARNING`, `DEBUG`, `CRITICAL`
41
+ - Colored output for better readability
42
+ - Symbol-based prefixes (e.g. `[+]`, `[-]`, `[!]`)
43
+
44
+ ### Multiple Output Formats
45
+
46
+ **Easily switch between different log styles:**
47
+
48
+ - `simple` → `[+] message`
49
+ - `simple2` → `[TIME] [+] message`
50
+ - `detailed` → `[TIME][LEVEL] : message`
51
+ - `file` → `[FILE:LINE][LEVEL] message`
52
+
53
+ ### Tag System
54
+
55
+ - Add custom tags to logs
56
+ - Supports multiple tags (e.g. `["API", "AUTH"]`)
57
+ - Optional default tags
58
+
59
+ ### File & Line Tracking
60
+
61
+ - Display caller file name and line number
62
+ - Useful for debugging large projects
63
+
64
+ ### Log File Saving
65
+
66
+ - Automatically save logs to files
67
+ - Output path: `./log/YYYY-MM-DD.log`
68
+ - Select which log levels to save
69
+
70
+ ### Auto Cleanup
71
+
72
+ - Automatically deletes old log files (default: 7 days)
73
+ - Keeps your log directory clean
74
+
75
+ ### Auto Cleanup
76
+
77
+ - Disable console output
78
+ - Useful for background services
79
+
80
+ ### Exception Handling
81
+
82
+ - Automatically captures unhandled exceptions
83
+ - Logs them as `CRITICAL`
84
+
85
+ ### Desktop Notifications
86
+
87
+ - Optional desktop alerts for errors and critical logs
88
+ - Uses `plyer.notification`
89
+
90
+ ### Asynchronous Logging
91
+
92
+ - Non-blocking log processing using threads and queues
93
+ - Improves performance in high-load environments
32
94
 
33
95
  ## Support
34
96
 
@@ -74,12 +136,4 @@ logger = VersaLog(enum="detailed", tag="a", show_tag=True)
74
136
 
75
137
  # two tag
76
138
  logger = VersaLog(enum="detailed", tag=["a", "a"], show_tag=True)
77
- ``` |
78
-
79
- ## Log save
80
-
81
- ````
82
-
83
- [2025-08-06 04:10:36][INFO] : ok
84
-
85
139
  ```
@@ -7,8 +7,69 @@
7
7
  [![Discord](https://img.shields.io/badge/Discord-Support%20Server-7289DA?style=flat&logo=discord)](https://discord.gg/Ms2ejEES)
8
8
 
9
9
  What is VersaLog.py?
10
- VersaLog is a powerful and flexible logging library for Python.
11
- It supports everything from simple usage to advanced, highly customizable configurations to meet a wide range of needs.
10
+
11
+ VersaLog is a modern, powerful, and flexible logging library for Python.
12
+ It supports everything from simple usage to advanced, highly customizable configurations, making it suitable for a wide range of use cases.
13
+
14
+ ## Feature
15
+
16
+ ### Basic Logging
17
+
18
+ - Supports standard log levels:
19
+ - `INFO`, `ERROR`, `WARNING`, `DEBUG`, `CRITICAL`
20
+ - Colored output for better readability
21
+ - Symbol-based prefixes (e.g. `[+]`, `[-]`, `[!]`)
22
+
23
+ ### Multiple Output Formats
24
+
25
+ **Easily switch between different log styles:**
26
+
27
+ - `simple` → `[+] message`
28
+ - `simple2` → `[TIME] [+] message`
29
+ - `detailed` → `[TIME][LEVEL] : message`
30
+ - `file` → `[FILE:LINE][LEVEL] message`
31
+
32
+ ### Tag System
33
+
34
+ - Add custom tags to logs
35
+ - Supports multiple tags (e.g. `["API", "AUTH"]`)
36
+ - Optional default tags
37
+
38
+ ### File & Line Tracking
39
+
40
+ - Display caller file name and line number
41
+ - Useful for debugging large projects
42
+
43
+ ### Log File Saving
44
+
45
+ - Automatically save logs to files
46
+ - Output path: `./log/YYYY-MM-DD.log`
47
+ - Select which log levels to save
48
+
49
+ ### Auto Cleanup
50
+
51
+ - Automatically deletes old log files (default: 7 days)
52
+ - Keeps your log directory clean
53
+
54
+ ### Auto Cleanup
55
+
56
+ - Disable console output
57
+ - Useful for background services
58
+
59
+ ### Exception Handling
60
+
61
+ - Automatically captures unhandled exceptions
62
+ - Logs them as `CRITICAL`
63
+
64
+ ### Desktop Notifications
65
+
66
+ - Optional desktop alerts for errors and critical logs
67
+ - Uses `plyer.notification`
68
+
69
+ ### Asynchronous Logging
70
+
71
+ - Non-blocking log processing using threads and queues
72
+ - Improves performance in high-load environments
12
73
 
13
74
  ## Support
14
75
 
@@ -54,12 +115,4 @@ logger = VersaLog(enum="detailed", tag="a", show_tag=True)
54
115
 
55
116
  # two tag
56
117
  logger = VersaLog(enum="detailed", tag=["a", "a"], show_tag=True)
57
- ``` |
58
-
59
- ## Log save
60
-
61
- ````
62
-
63
- [2025-08-06 04:10:36][INFO] : ok
64
-
65
118
  ```
@@ -0,0 +1,13 @@
1
+ from .core import VersaLog
2
+ from .handler import VersaLogHandler
3
+ from .integrations.auto import auto_setup
4
+ from .integrations.fastapi import setup_fastapi_logging
5
+ from .integrations.flask import setup_flask_logging
6
+ from .integrations.django import setup_django_logging
7
+
8
+ __copyright__ = "Copyright 2025 by Kayu0514"
9
+ __version__ = "2.6.0"
10
+ __author__ = "Kayu0514"
11
+ __url__ = "https://github.com/kayu0514"
12
+
13
+ __all__ = ["VersaLog", "VersaLogHandler", "auto_setup", "setup_fastapi_logging","setup_flask_logging", "setup_django_logging"]
@@ -87,7 +87,7 @@ class VersaLog:
87
87
  if self.save_levels is None:
88
88
  self.save_levels = self.valid_save_levels.copy()
89
89
  elif not isinstance(self.save_levels, list):
90
- raise ValueError(f"save_levels must be a list. Example: ['ERROR']")
90
+ raise ValueError("save_levels must be a list. Example: ['ERROR']")
91
91
  elif not all(level in self.valid_save_levels for level in self.save_levels):
92
92
  raise ValueError(f"Invalid save_levels specified. Valid levels are: {', '.join(self.valid_save_levels)}")
93
93
 
@@ -179,42 +179,39 @@ class VersaLog:
179
179
  tags = [final_tag] if final_tag else []
180
180
  else:
181
181
  tags = []
182
- tag_str = "".join(f"[{t}]" for t in tags) if tags else ""
182
+ tag_str = "".join(f"[{t}]" for t in tags)
183
183
 
184
184
  caller = self._GetCaller() if self.show_file or self.enum == "file" else ""
185
185
 
186
186
  if self.enum == "simple":
187
187
  symbol = self.SYMBOLS.get(tye, "[?]")
188
188
  if self.show_file:
189
- formatted = f"[{caller}]{tag_str}{colors}{symbol}{self.RESET} {msg}" if tag_str else f"[{caller}]{colors}{symbol}{self.RESET} {msg}"
190
- plain = f"[{caller}]{tag_str}{symbol} {msg}" if tag_str else f"[{caller}]{symbol} {msg}"
189
+ # tag_str is empty string if no tags, otherwise formatted as "[tag1][tag2]..."
190
+ formatted = f"[{caller}]{tag_str}{colors}{symbol}{self.RESET} {msg}"
191
+ plain = f"[{caller}]{tag_str}{symbol} {msg}"
191
192
  else:
192
- formatted = f"{tag_str}{colors}{symbol}{self.RESET} {msg}" if tag_str else f"{colors}{symbol}{self.RESET} {msg}"
193
- plain = f"{tag_str}{symbol} {msg}" if tag_str else f"{symbol} {msg}"
193
+ formatted = f"{tag_str}{colors}{symbol}{self.RESET} {msg}"
194
+ plain = f"{tag_str}{symbol} {msg}"
194
195
 
195
196
  elif self.enum == "simple2":
196
197
  symbol = self.SYMBOLS.get(tye, "[?]")
197
198
  time = self._GetTime()
198
199
  if self.show_file:
199
- formatted = f"[{time}] [{caller}]{tag_str}{colors}{symbol}{self.RESET} {msg}" if tag_str else f"[{time}] [{caller}]{colors}{symbol}{self.RESET} {msg}"
200
- plain = f"[{time}] [{caller}]{tag_str}{symbol} {msg}" if tag_str else f"[{time}] [{caller}]{symbol} {msg}"
200
+ formatted = f"[{time}] [{caller}]{tag_str}{colors}{symbol}{self.RESET} {msg}"
201
+ plain = f"[{time}] [{caller}]{tag_str}{symbol} {msg}"
201
202
  else:
202
- formatted = f"[{time}] {tag_str}{colors}{symbol}{self.RESET} {msg}" if tag_str else f"[{time}] {colors}{symbol}{self.RESET} {msg}"
203
- plain = f"[{time}] {tag_str}{symbol} {msg}" if tag_str else f"[{time}] {symbol} {msg}"
203
+ formatted = f"[{time}] {tag_str}{colors}{symbol}{self.RESET} {msg}"
204
+ plain = f"[{time}] {tag_str}{symbol} {msg}"
204
205
 
205
206
  elif self.enum == "file":
206
- formatted = f"[{caller}]{tag_str}{colors}[{types}]{self.RESET} {msg}" if tag_str else f"[{caller}]{colors}[{types}]{self.RESET} {msg}"
207
- plain = f"[{caller}]{tag_str}[{types}] {msg}" if tag_str else f"[{caller}][{types}] {msg}"
207
+ formatted = f"[{caller}]{tag_str}{colors}[{types}]{self.RESET} {msg}"
208
+ plain = f"[{caller}]{tag_str}[{types}] {msg}"
208
209
 
209
210
  else: # detailed
210
211
  time = self._GetTime()
211
- formatted = f"[{time}]{colors}[{types}]{self.RESET}{tag_str}" if tag_str else f"[{time}]{colors}[{types}]{self.RESET}"
212
- plain = f"[{time}][{types}]{tag_str}" if tag_str else f"[{time}][{types}]"
213
- if self.show_file:
214
- formatted += f"[{caller}]"
215
- plain += f"[{caller}]"
216
- formatted += f" : {msg}"
217
- plain += f" : {msg}"
212
+ caller_part = f"[{caller}]" if self.show_file else ""
213
+ formatted = f"[{time}]{colors}[{types}]{self.RESET}{tag_str}{caller_part} : {msg}"
214
+ plain = f"[{time}][{types}]{tag_str}{caller_part} : {msg}"
218
215
 
219
216
  if not self.silent:
220
217
  print(formatted)
@@ -0,0 +1,32 @@
1
+ import sys
2
+
3
+ from .generic import setup_logging
4
+ from .fastapi import setup_fastapi_logging
5
+ from .flask import setup_flask_logging
6
+ from .django import setup_django_logging
7
+
8
+
9
+ def auto_setup(versalog):
10
+ """
11
+ Automatically detects the runtime environment
12
+ and applies the appropriate logging configuration.
13
+ """
14
+
15
+ if "uvicorn" in sys.modules:
16
+ setup_fastapi_logging(versalog)
17
+ return "fastapi"
18
+
19
+ if "gunicorn" in sys.modules:
20
+ setup_fastapi_logging(versalog)
21
+ return "gunicorn"
22
+
23
+ if "flask" in sys.modules:
24
+ setup_flask_logging(None, versalog)
25
+ return "flask"
26
+
27
+ if "django" in sys.modules:
28
+ setup_django_logging(versalog)
29
+ return "django"
30
+
31
+ setup_logging(versalog)
32
+ return "generic"
@@ -0,0 +1,5 @@
1
+ from .generic import setup_logging
2
+
3
+
4
+ def setup_django_logging(versalog):
5
+ setup_logging(versalog)
@@ -0,0 +1,8 @@
1
+ from .generic import setup_logging
2
+
3
+
4
+ def setup_flask_logging(app, versalog):
5
+ setup_logging(versalog)
6
+
7
+ app.logger.handlers.clear()
8
+ app.logger.propagate = True
@@ -0,0 +1,14 @@
1
+ import logging
2
+ from ..handler import VersaLogHandler
3
+
4
+
5
+ def setup_logging(versalog):
6
+ handler = VersaLogHandler(versalog)
7
+
8
+ root = logging.getLogger()
9
+
10
+ for h in root.handlers[:]:
11
+ root.removeHandler(h)
12
+
13
+ root.setLevel(logging.NOTSET)
14
+ root.addHandler(handler)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: VersaLog
3
- Version: 2.5.4
3
+ Version: 2.6.0
4
4
  Summary: Versatile logging library.
5
5
  Home-page:
6
6
  Author:
@@ -17,6 +17,7 @@ Classifier: Operating System :: OS Independent
17
17
  Requires-Python: >=3.8, <3.14
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
+ Requires-Dist: plyer
20
21
 
21
22
  ## What is VersaLog.py?
22
23
 
@@ -27,8 +28,69 @@ License-File: LICENSE
27
28
  [![Discord](https://img.shields.io/badge/Discord-Support%20Server-7289DA?style=flat&logo=discord)](https://discord.gg/Ms2ejEES)
28
29
 
29
30
  What is VersaLog.py?
30
- VersaLog is a powerful and flexible logging library for Python.
31
- It supports everything from simple usage to advanced, highly customizable configurations to meet a wide range of needs.
31
+
32
+ VersaLog is a modern, powerful, and flexible logging library for Python.
33
+ It supports everything from simple usage to advanced, highly customizable configurations, making it suitable for a wide range of use cases.
34
+
35
+ ## Feature
36
+
37
+ ### Basic Logging
38
+
39
+ - Supports standard log levels:
40
+ - `INFO`, `ERROR`, `WARNING`, `DEBUG`, `CRITICAL`
41
+ - Colored output for better readability
42
+ - Symbol-based prefixes (e.g. `[+]`, `[-]`, `[!]`)
43
+
44
+ ### Multiple Output Formats
45
+
46
+ **Easily switch between different log styles:**
47
+
48
+ - `simple` → `[+] message`
49
+ - `simple2` → `[TIME] [+] message`
50
+ - `detailed` → `[TIME][LEVEL] : message`
51
+ - `file` → `[FILE:LINE][LEVEL] message`
52
+
53
+ ### Tag System
54
+
55
+ - Add custom tags to logs
56
+ - Supports multiple tags (e.g. `["API", "AUTH"]`)
57
+ - Optional default tags
58
+
59
+ ### File & Line Tracking
60
+
61
+ - Display caller file name and line number
62
+ - Useful for debugging large projects
63
+
64
+ ### Log File Saving
65
+
66
+ - Automatically save logs to files
67
+ - Output path: `./log/YYYY-MM-DD.log`
68
+ - Select which log levels to save
69
+
70
+ ### Auto Cleanup
71
+
72
+ - Automatically deletes old log files (default: 7 days)
73
+ - Keeps your log directory clean
74
+
75
+ ### Auto Cleanup
76
+
77
+ - Disable console output
78
+ - Useful for background services
79
+
80
+ ### Exception Handling
81
+
82
+ - Automatically captures unhandled exceptions
83
+ - Logs them as `CRITICAL`
84
+
85
+ ### Desktop Notifications
86
+
87
+ - Optional desktop alerts for errors and critical logs
88
+ - Uses `plyer.notification`
89
+
90
+ ### Asynchronous Logging
91
+
92
+ - Non-blocking log processing using threads and queues
93
+ - Improves performance in high-load environments
32
94
 
33
95
  ## Support
34
96
 
@@ -74,12 +136,4 @@ logger = VersaLog(enum="detailed", tag="a", show_tag=True)
74
136
 
75
137
  # two tag
76
138
  logger = VersaLog(enum="detailed", tag=["a", "a"], show_tag=True)
77
- ``` |
78
-
79
- ## Log save
80
-
81
- ````
82
-
83
- [2025-08-06 04:10:36][INFO] : ok
84
-
85
139
  ```
@@ -7,6 +7,11 @@ VersaLog/handler.py
7
7
  VersaLog.egg-info/PKG-INFO
8
8
  VersaLog.egg-info/SOURCES.txt
9
9
  VersaLog.egg-info/dependency_links.txt
10
+ VersaLog.egg-info/requires.txt
10
11
  VersaLog.egg-info/top_level.txt
11
12
  VersaLog/integrations/__init__.py
12
- VersaLog/integrations/fastapi.py
13
+ VersaLog/integrations/auto.py
14
+ VersaLog/integrations/django.py
15
+ VersaLog/integrations/fastapi.py
16
+ VersaLog/integrations/flask.py
17
+ VersaLog/integrations/generic.py
@@ -0,0 +1 @@
1
+ plyer
@@ -5,7 +5,7 @@ with open("README.md", encoding="utf-8") as f:
5
5
 
6
6
  setup(
7
7
  name="VersaLog",
8
- version="2.5.4",
8
+ version="2.6.0",
9
9
  description="Versatile logging library.",
10
10
  long_description=long_description,
11
11
  long_description_content_type="text/markdown",
@@ -13,7 +13,9 @@ setup(
13
13
  license="MIT",
14
14
  packages=find_packages(include=["VersaLog", "VersaLog.*"]),
15
15
  include_package_data=True,
16
- install_requires=[],
16
+ install_requires=[
17
+ "plyer"
18
+ ],
17
19
  python_requires=">=3.8, <3.14",
18
20
  url="",
19
21
  classifiers=[
@@ -1,10 +0,0 @@
1
- from .core import VersaLog
2
- from .handler import VersaLogHandler
3
- from .integrations.fastapi import setup_fastapi_logging
4
-
5
- __copyright__ = "Copyright 2025 by Kayu0514"
6
- __version__ = "2.5.4"
7
- __author__ = "Kayu0514"
8
- __url__ = "https://github.com/kayu0514"
9
-
10
- __all__ = ["VersaLog", "VersaLogHandler", "setup_fastapi_logging"]
File without changes
File without changes
File without changes