webscout 7.1__py3-none-any.whl → 7.3__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.
Potentially problematic release.
This version of webscout might be problematic. Click here for more details.
- webscout/AIauto.py +191 -191
- webscout/AIbase.py +122 -122
- webscout/AIutel.py +440 -440
- webscout/Bard.py +343 -161
- webscout/DWEBS.py +489 -492
- webscout/Extra/YTToolkit/YTdownloader.py +995 -995
- webscout/Extra/YTToolkit/__init__.py +2 -2
- webscout/Extra/YTToolkit/transcriber.py +476 -479
- webscout/Extra/YTToolkit/ytapi/channel.py +307 -307
- webscout/Extra/YTToolkit/ytapi/playlist.py +58 -58
- webscout/Extra/YTToolkit/ytapi/pool.py +7 -7
- webscout/Extra/YTToolkit/ytapi/utils.py +62 -62
- webscout/Extra/YTToolkit/ytapi/video.py +103 -103
- webscout/Extra/autocoder/__init__.py +9 -9
- webscout/Extra/autocoder/autocoder_utiles.py +199 -199
- webscout/Extra/autocoder/rawdog.py +5 -7
- webscout/Extra/autollama.py +230 -230
- webscout/Extra/gguf.py +3 -3
- webscout/Extra/weather.py +171 -171
- webscout/LLM.py +442 -442
- webscout/Litlogger/__init__.py +67 -681
- webscout/Litlogger/core/__init__.py +6 -0
- webscout/Litlogger/core/level.py +23 -0
- webscout/Litlogger/core/logger.py +166 -0
- webscout/Litlogger/handlers/__init__.py +12 -0
- webscout/Litlogger/handlers/console.py +33 -0
- webscout/Litlogger/handlers/file.py +143 -0
- webscout/Litlogger/handlers/network.py +173 -0
- webscout/Litlogger/styles/__init__.py +7 -0
- webscout/Litlogger/styles/colors.py +249 -0
- webscout/Litlogger/styles/formats.py +460 -0
- webscout/Litlogger/styles/text.py +87 -0
- webscout/Litlogger/utils/__init__.py +6 -0
- webscout/Litlogger/utils/detectors.py +154 -0
- webscout/Litlogger/utils/formatters.py +200 -0
- webscout/Provider/AISEARCH/DeepFind.py +250 -250
- webscout/Provider/AISEARCH/ISou.py +277 -0
- webscout/Provider/AISEARCH/__init__.py +2 -1
- webscout/Provider/Blackboxai.py +3 -3
- webscout/Provider/ChatGPTGratis.py +226 -0
- webscout/Provider/Cloudflare.py +3 -4
- webscout/Provider/DeepSeek.py +218 -0
- webscout/Provider/Deepinfra.py +40 -24
- webscout/Provider/Free2GPT.py +131 -124
- webscout/Provider/Gemini.py +100 -115
- webscout/Provider/Glider.py +3 -3
- webscout/Provider/Groq.py +5 -1
- webscout/Provider/Jadve.py +3 -3
- webscout/Provider/Marcus.py +191 -192
- webscout/Provider/Netwrck.py +3 -3
- webscout/Provider/PI.py +2 -2
- webscout/Provider/PizzaGPT.py +2 -3
- webscout/Provider/QwenLM.py +311 -0
- webscout/Provider/TTI/AiForce/__init__.py +22 -22
- webscout/Provider/TTI/AiForce/async_aiforce.py +257 -257
- webscout/Provider/TTI/AiForce/sync_aiforce.py +242 -242
- webscout/Provider/TTI/FreeAIPlayground/__init__.py +9 -0
- webscout/Provider/TTI/FreeAIPlayground/async_freeaiplayground.py +206 -0
- webscout/Provider/TTI/FreeAIPlayground/sync_freeaiplayground.py +192 -0
- webscout/Provider/TTI/Nexra/__init__.py +22 -22
- webscout/Provider/TTI/Nexra/async_nexra.py +286 -286
- webscout/Provider/TTI/Nexra/sync_nexra.py +258 -258
- webscout/Provider/TTI/PollinationsAI/__init__.py +23 -23
- webscout/Provider/TTI/PollinationsAI/async_pollinations.py +330 -330
- webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +285 -285
- webscout/Provider/TTI/__init__.py +2 -1
- webscout/Provider/TTI/artbit/__init__.py +22 -22
- webscout/Provider/TTI/artbit/async_artbit.py +184 -184
- webscout/Provider/TTI/artbit/sync_artbit.py +176 -176
- webscout/Provider/TTI/blackbox/__init__.py +4 -4
- webscout/Provider/TTI/blackbox/async_blackbox.py +212 -212
- webscout/Provider/TTI/blackbox/sync_blackbox.py +199 -199
- webscout/Provider/TTI/deepinfra/__init__.py +4 -4
- webscout/Provider/TTI/deepinfra/async_deepinfra.py +227 -227
- webscout/Provider/TTI/deepinfra/sync_deepinfra.py +199 -199
- webscout/Provider/TTI/huggingface/__init__.py +22 -22
- webscout/Provider/TTI/huggingface/async_huggingface.py +199 -199
- webscout/Provider/TTI/huggingface/sync_huggingface.py +195 -195
- webscout/Provider/TTI/imgninza/__init__.py +4 -4
- webscout/Provider/TTI/imgninza/async_ninza.py +214 -214
- webscout/Provider/TTI/imgninza/sync_ninza.py +209 -209
- webscout/Provider/TTI/talkai/__init__.py +4 -4
- webscout/Provider/TTI/talkai/async_talkai.py +229 -229
- webscout/Provider/TTI/talkai/sync_talkai.py +207 -207
- webscout/Provider/TTS/deepgram.py +182 -182
- webscout/Provider/TTS/elevenlabs.py +136 -136
- webscout/Provider/TTS/gesserit.py +150 -150
- webscout/Provider/TTS/murfai.py +138 -138
- webscout/Provider/TTS/parler.py +133 -134
- webscout/Provider/TTS/streamElements.py +360 -360
- webscout/Provider/TTS/utils.py +280 -280
- webscout/Provider/TTS/voicepod.py +116 -116
- webscout/Provider/TextPollinationsAI.py +28 -8
- webscout/Provider/WiseCat.py +193 -0
- webscout/Provider/__init__.py +146 -134
- webscout/Provider/cerebras.py +242 -227
- webscout/Provider/chatglm.py +204 -204
- webscout/Provider/dgaf.py +2 -3
- webscout/Provider/freeaichat.py +221 -0
- webscout/Provider/gaurish.py +2 -3
- webscout/Provider/geminiapi.py +208 -208
- webscout/Provider/granite.py +223 -0
- webscout/Provider/hermes.py +218 -218
- webscout/Provider/llama3mitril.py +179 -179
- webscout/Provider/llamatutor.py +3 -3
- webscout/Provider/llmchat.py +2 -3
- webscout/Provider/meta.py +794 -794
- webscout/Provider/multichat.py +331 -331
- webscout/Provider/typegpt.py +359 -359
- webscout/Provider/yep.py +3 -3
- webscout/__init__.py +1 -0
- webscout/__main__.py +5 -5
- webscout/cli.py +319 -319
- webscout/conversation.py +241 -242
- webscout/exceptions.py +328 -328
- webscout/litagent/__init__.py +28 -28
- webscout/litagent/agent.py +2 -3
- webscout/litprinter/__init__.py +0 -58
- webscout/scout/__init__.py +8 -8
- webscout/scout/core.py +884 -884
- webscout/scout/element.py +459 -459
- webscout/scout/parsers/__init__.py +69 -69
- webscout/scout/parsers/html5lib_parser.py +172 -172
- webscout/scout/parsers/html_parser.py +236 -236
- webscout/scout/parsers/lxml_parser.py +178 -178
- webscout/scout/utils.py +38 -38
- webscout/swiftcli/__init__.py +811 -811
- webscout/update_checker.py +2 -12
- webscout/version.py +1 -1
- webscout/webscout_search.py +87 -6
- webscout/webscout_search_async.py +58 -1
- webscout/yep_search.py +297 -0
- webscout/zeroart/__init__.py +54 -54
- webscout/zeroart/base.py +60 -60
- webscout/zeroart/effects.py +99 -99
- webscout/zeroart/fonts.py +816 -816
- {webscout-7.1.dist-info → webscout-7.3.dist-info}/METADATA +62 -22
- webscout-7.3.dist-info/RECORD +223 -0
- {webscout-7.1.dist-info → webscout-7.3.dist-info}/WHEEL +1 -1
- webstoken/__init__.py +30 -30
- webstoken/classifier.py +189 -189
- webstoken/keywords.py +216 -216
- webstoken/language.py +128 -128
- webstoken/ner.py +164 -164
- webstoken/normalizer.py +35 -35
- webstoken/processor.py +77 -77
- webstoken/sentiment.py +206 -206
- webstoken/stemmer.py +73 -73
- webstoken/tagger.py +60 -60
- webstoken/tokenizer.py +158 -158
- webscout-7.1.dist-info/RECORD +0 -198
- {webscout-7.1.dist-info → webscout-7.3.dist-info}/LICENSE.md +0 -0
- {webscout-7.1.dist-info → webscout-7.3.dist-info}/entry_points.txt +0 -0
- {webscout-7.1.dist-info → webscout-7.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# Terminal Color Management System
|
|
2
|
+
# Provides extensive ANSI color support with themes, gradients, and animations
|
|
3
|
+
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from ..core.level import LogLevel
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class LogColors:
|
|
9
|
+
"""
|
|
10
|
+
Comprehensive terminal color and styling system with support for:
|
|
11
|
+
- Basic and bright colors (foreground/background)
|
|
12
|
+
- RGB and 256-color modes
|
|
13
|
+
- Text styles (bold, italic, etc.)
|
|
14
|
+
- Gradients and animations
|
|
15
|
+
- Predefined themes
|
|
16
|
+
"""
|
|
17
|
+
# Reset
|
|
18
|
+
RESET = "\033[0m"
|
|
19
|
+
|
|
20
|
+
# Regular colors
|
|
21
|
+
BLACK = "\033[30m"
|
|
22
|
+
RED = "\033[31m"
|
|
23
|
+
GREEN = "\033[32m"
|
|
24
|
+
YELLOW = "\033[33m"
|
|
25
|
+
BLUE = "\033[34m"
|
|
26
|
+
MAGENTA = "\033[35m"
|
|
27
|
+
CYAN = "\033[36m"
|
|
28
|
+
WHITE = "\033[37m"
|
|
29
|
+
|
|
30
|
+
# Background colors
|
|
31
|
+
BG_BLACK = "\033[40m"
|
|
32
|
+
BG_RED = "\033[41m"
|
|
33
|
+
BG_GREEN = "\033[42m"
|
|
34
|
+
BG_YELLOW = "\033[43m"
|
|
35
|
+
BG_BLUE = "\033[44m"
|
|
36
|
+
BG_MAGENTA = "\033[45m"
|
|
37
|
+
BG_CYAN = "\033[46m"
|
|
38
|
+
BG_WHITE = "\033[47m"
|
|
39
|
+
|
|
40
|
+
# Bright colors
|
|
41
|
+
BRIGHT_BLACK = "\033[90m"
|
|
42
|
+
BRIGHT_RED = "\033[91m"
|
|
43
|
+
BRIGHT_GREEN = "\033[92m"
|
|
44
|
+
BRIGHT_YELLOW = "\033[93m"
|
|
45
|
+
BRIGHT_BLUE = "\033[94m"
|
|
46
|
+
BRIGHT_MAGENTA = "\033[95m"
|
|
47
|
+
BRIGHT_CYAN = "\033[96m"
|
|
48
|
+
BRIGHT_WHITE = "\033[97m"
|
|
49
|
+
|
|
50
|
+
# Bright background colors
|
|
51
|
+
BG_BRIGHT_BLACK = "\033[100m"
|
|
52
|
+
BG_BRIGHT_RED = "\033[101m"
|
|
53
|
+
BG_BRIGHT_GREEN = "\033[102m"
|
|
54
|
+
BG_BRIGHT_YELLOW = "\033[103m"
|
|
55
|
+
BG_BRIGHT_BLUE = "\033[104m"
|
|
56
|
+
BG_BRIGHT_MAGENTA = "\033[105m"
|
|
57
|
+
BG_BRIGHT_CYAN = "\033[106m"
|
|
58
|
+
BG_BRIGHT_WHITE = "\033[107m"
|
|
59
|
+
|
|
60
|
+
# Custom theme colors using RGB
|
|
61
|
+
FIRE = "\033[38;2;255;100;0m" # Orange-red
|
|
62
|
+
ICE = "\033[38;2;150;230;255m" # Light blue
|
|
63
|
+
GRASS = "\033[38;2;120;200;80m" # Light green
|
|
64
|
+
PURPLE = "\033[38;2;147;112;219m" # Medium purple
|
|
65
|
+
GOLD = "\033[38;2;255;215;0m" # Golden
|
|
66
|
+
|
|
67
|
+
# Gradient colors
|
|
68
|
+
SUNSET_START = "\033[38;2;255;128;0m" # Orange
|
|
69
|
+
SUNSET_END = "\033[38;2;255;51;153m" # Pink
|
|
70
|
+
|
|
71
|
+
OCEAN_START = "\033[38;2;0;204;255m" # Light blue
|
|
72
|
+
OCEAN_END = "\033[38;2;0;51;102m" # Dark blue
|
|
73
|
+
|
|
74
|
+
FOREST_START = "\033[38;2;34;139;34m" # Forest green
|
|
75
|
+
FOREST_END = "\033[38;2;0;100;0m" # Dark green
|
|
76
|
+
|
|
77
|
+
# Bold
|
|
78
|
+
BOLD = "\033[1m"
|
|
79
|
+
|
|
80
|
+
# Styles
|
|
81
|
+
DIM = "\033[2m"
|
|
82
|
+
ITALIC = "\033[3m"
|
|
83
|
+
UNDERLINE = "\033[4m"
|
|
84
|
+
|
|
85
|
+
# Level color mapping
|
|
86
|
+
LEVEL_COLORS = {
|
|
87
|
+
LogLevel.DEBUG: BRIGHT_BLACK,
|
|
88
|
+
LogLevel.INFO: BRIGHT_BLUE,
|
|
89
|
+
LogLevel.WARNING: BRIGHT_YELLOW,
|
|
90
|
+
LogLevel.ERROR: BRIGHT_RED,
|
|
91
|
+
LogLevel.CRITICAL: BRIGHT_RED + BOLD,
|
|
92
|
+
LogLevel.NOTSET: WHITE
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# Add style combinations
|
|
96
|
+
STYLES = {
|
|
97
|
+
"bold": "\033[1m",
|
|
98
|
+
"dim": "\033[2m",
|
|
99
|
+
"italic": "\033[3m",
|
|
100
|
+
"underline": "\033[4m",
|
|
101
|
+
"blink": "\033[5m",
|
|
102
|
+
"reverse": "\033[7m",
|
|
103
|
+
"hidden": "\033[8m",
|
|
104
|
+
"strike": "\033[9m",
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@staticmethod
|
|
108
|
+
def rgb(r: int, g: int, b: int, background: bool = False) -> str:
|
|
109
|
+
"""Create RGB color code."""
|
|
110
|
+
if background:
|
|
111
|
+
return f"\033[48;2;{r};{g};{b}m"
|
|
112
|
+
return f"\033[38;2;{r};{g};{b}m"
|
|
113
|
+
|
|
114
|
+
@staticmethod
|
|
115
|
+
def color_256(code: int, background: bool = False) -> str:
|
|
116
|
+
"""Create 256-color code."""
|
|
117
|
+
if background:
|
|
118
|
+
return f"\033[48;5;{code}m"
|
|
119
|
+
return f"\033[38;5;{code}m"
|
|
120
|
+
|
|
121
|
+
@staticmethod
|
|
122
|
+
def combine(*colors):
|
|
123
|
+
return "".join(colors)
|
|
124
|
+
|
|
125
|
+
@staticmethod
|
|
126
|
+
def gradient(text: str, start_rgb: tuple, end_rgb: tuple) -> str:
|
|
127
|
+
"""Create a gradient effect across text."""
|
|
128
|
+
if len(text) < 2:
|
|
129
|
+
return LogColors.rgb(*start_rgb) + text
|
|
130
|
+
|
|
131
|
+
result = []
|
|
132
|
+
for i, char in enumerate(text):
|
|
133
|
+
r = int(start_rgb[0] + (end_rgb[0] - start_rgb[0]) * i / (len(text) - 1))
|
|
134
|
+
g = int(start_rgb[1] + (end_rgb[1] - start_rgb[1]) * i / (len(text) - 1))
|
|
135
|
+
b = int(start_rgb[2] + (end_rgb[2] - start_rgb[2]) * i / (len(text) - 1))
|
|
136
|
+
result.append(f"{LogColors.rgb(r, g, b)}{char}")
|
|
137
|
+
|
|
138
|
+
return "".join(result) + LogColors.RESET
|
|
139
|
+
|
|
140
|
+
@staticmethod
|
|
141
|
+
def rainbow(text: str) -> str:
|
|
142
|
+
"""Apply rainbow colors to text."""
|
|
143
|
+
colors = [
|
|
144
|
+
(255, 0, 0), # Red
|
|
145
|
+
(255, 127, 0), # Orange
|
|
146
|
+
(255, 255, 0), # Yellow
|
|
147
|
+
(0, 255, 0), # Green
|
|
148
|
+
(0, 0, 255), # Blue
|
|
149
|
+
(75, 0, 130), # Indigo
|
|
150
|
+
(148, 0, 211) # Violet
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
result = []
|
|
154
|
+
for i, char in enumerate(text):
|
|
155
|
+
color = colors[i % len(colors)]
|
|
156
|
+
result.append(f"{LogColors.rgb(*color)}{char}")
|
|
157
|
+
|
|
158
|
+
return "".join(result) + LogColors.RESET
|
|
159
|
+
|
|
160
|
+
@staticmethod
|
|
161
|
+
def animate(text: str, effect: str = "blink") -> str:
|
|
162
|
+
"""Apply animation effects to text."""
|
|
163
|
+
effects = {
|
|
164
|
+
"blink": LogColors.BLINK,
|
|
165
|
+
"reverse": LogColors.REVERSE,
|
|
166
|
+
"bold_blink": LogColors.combine(LogColors.BOLD, LogColors.BLINK),
|
|
167
|
+
"frame_blink": LogColors.combine(LogColors.FRAME, LogColors.BLINK),
|
|
168
|
+
"encircle_blink": LogColors.combine(LogColors.ENCIRCLE, LogColors.BLINK)
|
|
169
|
+
}
|
|
170
|
+
return effects.get(effect, LogColors.BLINK) + text + LogColors.RESET
|
|
171
|
+
|
|
172
|
+
@staticmethod
|
|
173
|
+
def style_text(text: str, *styles: str, color: Optional[str] = None) -> str:
|
|
174
|
+
"""Apply multiple styles and color to text."""
|
|
175
|
+
style_codes = "".join(LogColors.STYLES.get(style, "") for style in styles)
|
|
176
|
+
color_code = color if color else ""
|
|
177
|
+
return f"{style_codes}{color_code}{text}{LogColors.RESET}"
|
|
178
|
+
|
|
179
|
+
@staticmethod
|
|
180
|
+
def level_style(level: LogLevel, text: str) -> str:
|
|
181
|
+
"""Style text according to log level with enhanced formatting."""
|
|
182
|
+
color = LogColors.LEVEL_COLORS.get(level, LogColors.RESET)
|
|
183
|
+
|
|
184
|
+
# Apply appropriate styling based on level
|
|
185
|
+
if level == LogLevel.CRITICAL:
|
|
186
|
+
return f"{color}{LogColors.STYLES['bold']}{text}{LogColors.RESET}"
|
|
187
|
+
elif level == LogLevel.ERROR:
|
|
188
|
+
return f"{color}{text}{LogColors.RESET}"
|
|
189
|
+
elif level == LogLevel.WARNING:
|
|
190
|
+
return f"{color}{text}{LogColors.RESET}"
|
|
191
|
+
else:
|
|
192
|
+
return f"{color}{text}{LogColors.RESET}"
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class LogTheme:
|
|
196
|
+
"""Pre-defined color themes and combinations."""
|
|
197
|
+
|
|
198
|
+
@staticmethod
|
|
199
|
+
def get_theme(name: str) -> str:
|
|
200
|
+
themes = {
|
|
201
|
+
# Status themes
|
|
202
|
+
"success": LogColors.combine(LogColors.BRIGHT_GREEN, LogColors.BOLD),
|
|
203
|
+
"error": LogColors.combine(LogColors.BRIGHT_RED, LogColors.BOLD),
|
|
204
|
+
"warning": LogColors.combine(LogColors.BRIGHT_YELLOW, LogColors.BOLD),
|
|
205
|
+
"info": LogColors.combine(LogColors.BRIGHT_BLUE, LogColors.BOLD),
|
|
206
|
+
"debug": LogColors.combine(LogColors.DIM, LogColors.WHITE),
|
|
207
|
+
"critical": LogColors.combine(LogColors.BG_RED, LogColors.WHITE, LogColors.BOLD),
|
|
208
|
+
|
|
209
|
+
# Special themes
|
|
210
|
+
"header": LogColors.combine(LogColors.BRIGHT_WHITE, LogColors.BOLD, LogColors.UNDERLINE),
|
|
211
|
+
"highlight": LogColors.combine(LogColors.BLACK, LogColors.BG_BRIGHT_YELLOW),
|
|
212
|
+
"important": LogColors.combine(LogColors.BRIGHT_RED, LogColors.BOLD, LogColors.UNDERLINE),
|
|
213
|
+
"subtle": LogColors.combine(LogColors.DIM, LogColors.BRIGHT_BLACK),
|
|
214
|
+
|
|
215
|
+
# UI themes
|
|
216
|
+
"title": LogColors.combine(LogColors.BRIGHT_WHITE, LogColors.BOLD, LogColors.UNDERLINE),
|
|
217
|
+
"subtitle": LogColors.combine(LogColors.BRIGHT_WHITE, LogColors.DIM),
|
|
218
|
+
"link": LogColors.combine(LogColors.BLUE, LogColors.UNDERLINE),
|
|
219
|
+
"code": LogColors.combine(LogColors.BRIGHT_BLACK, LogColors.BG_WHITE),
|
|
220
|
+
|
|
221
|
+
# Data themes
|
|
222
|
+
"number": LogColors.combine(LogColors.BRIGHT_CYAN, LogColors.BOLD),
|
|
223
|
+
"string": LogColors.combine(LogColors.BRIGHT_GREEN),
|
|
224
|
+
"boolean": LogColors.combine(LogColors.BRIGHT_YELLOW, LogColors.BOLD),
|
|
225
|
+
"null": LogColors.combine(LogColors.DIM, LogColors.ITALIC),
|
|
226
|
+
|
|
227
|
+
# Custom themes
|
|
228
|
+
"fire": LogColors.combine(LogColors.FIRE, LogColors.BOLD),
|
|
229
|
+
"ice": LogColors.combine(LogColors.ICE, LogColors.BOLD),
|
|
230
|
+
"nature": LogColors.combine(LogColors.GRASS, LogColors.BOLD),
|
|
231
|
+
"royal": LogColors.combine(LogColors.PURPLE, LogColors.BOLD),
|
|
232
|
+
"precious": LogColors.combine(LogColors.GOLD, LogColors.BOLD),
|
|
233
|
+
|
|
234
|
+
# Gradient themes
|
|
235
|
+
"sunset": LogColors.combine(LogColors.SUNSET_START, LogColors.SUNSET_END),
|
|
236
|
+
"ocean": LogColors.combine(LogColors.OCEAN_START, LogColors.OCEAN_END),
|
|
237
|
+
"forest": LogColors.combine(LogColors.FOREST_START, LogColors.FOREST_END),
|
|
238
|
+
}
|
|
239
|
+
return themes.get(name, LogColors.RESET)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
# Define level colors after both classes are defined
|
|
243
|
+
LogColors.LEVEL_COLORS = {
|
|
244
|
+
"DEBUG": LogTheme.get_theme("debug"),
|
|
245
|
+
"INFO": LogTheme.get_theme("info"),
|
|
246
|
+
"WARNING": LogTheme.get_theme("warning"),
|
|
247
|
+
"ERROR": LogTheme.get_theme("error"),
|
|
248
|
+
"CRITICAL": LogTheme.get_theme("critical")
|
|
249
|
+
}
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from typing import Dict
|
|
3
|
+
|
|
4
|
+
class LogFormat:
|
|
5
|
+
# Basic formats with improved styling
|
|
6
|
+
MINIMAL = "│ {time} │ {level} │ {message}"
|
|
7
|
+
STANDARD = "┌─ {time} ─┐\n│ {level} │ {name}: {message}"
|
|
8
|
+
DETAILED = """╭──────────────────────╮
|
|
9
|
+
│ {time}
|
|
10
|
+
│ {level} • {name}
|
|
11
|
+
│ {file}:{line}
|
|
12
|
+
├──────────────────────┤
|
|
13
|
+
│ {message}
|
|
14
|
+
╰──────────────────────╯"""
|
|
15
|
+
SIMPLE = "• {message}"
|
|
16
|
+
COMPACT = "⟦{time}⟧ {level} ⟫ {message}"
|
|
17
|
+
|
|
18
|
+
# Modern Styles with Unicode
|
|
19
|
+
MODERN = """┌────────────────────┐
|
|
20
|
+
│ {time}
|
|
21
|
+
├────────────────────┤
|
|
22
|
+
│ {level} • {name}
|
|
23
|
+
│ {message}
|
|
24
|
+
└────────────────────┘"""
|
|
25
|
+
|
|
26
|
+
MODERN_EMOJI = """╭─ {emoji} {time} ─╮
|
|
27
|
+
│ {level}
|
|
28
|
+
├───────────────────
|
|
29
|
+
│ {message}
|
|
30
|
+
╰───────────────────"""
|
|
31
|
+
|
|
32
|
+
MODERN_CLEAN = """• {time} •
|
|
33
|
+
┌─ {level}
|
|
34
|
+
└→ {message}"""
|
|
35
|
+
|
|
36
|
+
MODERN_BRACKET = """【{time}】
|
|
37
|
+
「{level}」{message}"""
|
|
38
|
+
|
|
39
|
+
MODERN_PLUS = """⊕ {time}
|
|
40
|
+
├─ {level}
|
|
41
|
+
└─ {message}"""
|
|
42
|
+
|
|
43
|
+
MODERN_DOT = """● {time}
|
|
44
|
+
├● {level}
|
|
45
|
+
└● {message}"""
|
|
46
|
+
|
|
47
|
+
MODERN_ARROW = """➤ {time}
|
|
48
|
+
├➤ {level}
|
|
49
|
+
└➤ {message}"""
|
|
50
|
+
|
|
51
|
+
# Boxed Styles
|
|
52
|
+
BOXED = """
|
|
53
|
+
╭─────────────────────╮
|
|
54
|
+
│ [{time}]
|
|
55
|
+
│ {level} - {name}
|
|
56
|
+
│ {message}
|
|
57
|
+
╰─────────────────────╯"""
|
|
58
|
+
|
|
59
|
+
DOUBLE_BOX = """
|
|
60
|
+
╔══════════════════════╗
|
|
61
|
+
║ {level} @ {time}
|
|
62
|
+
║ {name}
|
|
63
|
+
║ {message}
|
|
64
|
+
╚══════════════════════╝"""
|
|
65
|
+
|
|
66
|
+
ROUNDED_BOX = """
|
|
67
|
+
╭──────────────────────╮
|
|
68
|
+
│ {time} • {level}
|
|
69
|
+
├──────────────────────┤
|
|
70
|
+
│ {message}
|
|
71
|
+
╰──────────────────────╯"""
|
|
72
|
+
|
|
73
|
+
RAINBOW_BOX = """
|
|
74
|
+
{level} - {time}
|
|
75
|
+
{name}: {message}
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
HEAVY_BOX = """
|
|
79
|
+
┏━━━━━━━━━━━━━━━━━━━━┓
|
|
80
|
+
┃ {time}
|
|
81
|
+
┃ {level} | {name}
|
|
82
|
+
┃ {message}
|
|
83
|
+
┗━━━━━━━━━━━━━━━━━━━━┛"""
|
|
84
|
+
|
|
85
|
+
DOTTED_BOX = """
|
|
86
|
+
╭┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮
|
|
87
|
+
┊ {time} | {level}
|
|
88
|
+
┊ {message}
|
|
89
|
+
╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╯"""
|
|
90
|
+
|
|
91
|
+
# Debug & Development
|
|
92
|
+
DEBUG = "[{time}] {level} {name} ({file}:{line}) {message}"
|
|
93
|
+
DEBUG_FULL = """
|
|
94
|
+
┌─ Debug Info ─┐
|
|
95
|
+
│ Time: {time}
|
|
96
|
+
│ Level: {level}
|
|
97
|
+
│ Name: {name}
|
|
98
|
+
│ File: {file}:{line}
|
|
99
|
+
│ Message: {message}
|
|
100
|
+
└──────────────┘"""
|
|
101
|
+
|
|
102
|
+
TRACE = """
|
|
103
|
+
Trace Details:
|
|
104
|
+
Time: {time}
|
|
105
|
+
Level: {level}
|
|
106
|
+
Location: {file}:{line}
|
|
107
|
+
Message: {message}"""
|
|
108
|
+
|
|
109
|
+
DEBUG_COMPACT = "[DBG][{time}] {message} @{file}:{line}"
|
|
110
|
+
DEBUG_EXTENDED = """
|
|
111
|
+
🔍 Debug Information 🔍
|
|
112
|
+
⏰ Time: {time}
|
|
113
|
+
📊 Level: {level}
|
|
114
|
+
📂 File: {file}
|
|
115
|
+
📍 Line: {line}
|
|
116
|
+
💬 Message: {message}
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
# Enhanced Error Formats
|
|
120
|
+
ERROR = """╔══ ERROR ══╗
|
|
121
|
+
║ Time: {time}
|
|
122
|
+
║ Level: {level}
|
|
123
|
+
║ Component: {name}
|
|
124
|
+
╟──────────────
|
|
125
|
+
║ {message}
|
|
126
|
+
╚════════════╝"""
|
|
127
|
+
|
|
128
|
+
ERROR_DETAILED = """┏━━ ALERT ━━┓
|
|
129
|
+
┃ Time: {time}
|
|
130
|
+
┃ Level: {level}
|
|
131
|
+
┃ Component: {name}
|
|
132
|
+
┃ Location: {file}:{line}
|
|
133
|
+
┣━━━━━━━━━━━
|
|
134
|
+
┃ {message}
|
|
135
|
+
┗━━━━━━━━━━━┛"""
|
|
136
|
+
|
|
137
|
+
ERROR_COMPACT = "‼ [{time}] {level}: {message}"
|
|
138
|
+
|
|
139
|
+
ERROR_EMOJI = """❌ ERROR REPORT
|
|
140
|
+
⏰ {time}
|
|
141
|
+
⚠️ {level}
|
|
142
|
+
📝 {message}"""
|
|
143
|
+
|
|
144
|
+
ERROR_BLOCK = """█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
|
|
145
|
+
█ ERROR @ {time}
|
|
146
|
+
█ {level}
|
|
147
|
+
█ {message}
|
|
148
|
+
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█"""
|
|
149
|
+
|
|
150
|
+
# Status & Progress with Better Visual Hierarchy
|
|
151
|
+
STATUS = """┌─── Status Update ───┐
|
|
152
|
+
│ Time: {time}
|
|
153
|
+
│ Level: {level}
|
|
154
|
+
│ Component: {name}
|
|
155
|
+
├───────────────────┤
|
|
156
|
+
│ {message}
|
|
157
|
+
└───────────────────┘"""
|
|
158
|
+
|
|
159
|
+
PROGRESS = """╭── Progress Report ──╮
|
|
160
|
+
│ Time: {time}
|
|
161
|
+
│ Level: {level}
|
|
162
|
+
├────────────────────
|
|
163
|
+
│ Component: {name}
|
|
164
|
+
│ Status: {message}
|
|
165
|
+
╰────────────────────"""
|
|
166
|
+
|
|
167
|
+
PROGRESS_SIMPLE = "► {time} | {level} | {message}"
|
|
168
|
+
PROGRESS_BAR = "[{progress_bar}] {percentage}% - {message}"
|
|
169
|
+
|
|
170
|
+
# Network & API
|
|
171
|
+
HTTP = """
|
|
172
|
+
API {level} [{time}]
|
|
173
|
+
Endpoint: {name}
|
|
174
|
+
Response: {message}"""
|
|
175
|
+
|
|
176
|
+
REQUEST = """
|
|
177
|
+
→ Incoming Request
|
|
178
|
+
Time: {time}
|
|
179
|
+
Level: {level}
|
|
180
|
+
API: {name}
|
|
181
|
+
Details: {message}"""
|
|
182
|
+
|
|
183
|
+
RESPONSE = """
|
|
184
|
+
← Outgoing Response
|
|
185
|
+
Time: {time}
|
|
186
|
+
Level: {level}
|
|
187
|
+
API: {name}
|
|
188
|
+
Details: {message}"""
|
|
189
|
+
|
|
190
|
+
API_COMPACT = "{method} {url} - {status_code} ({time})"
|
|
191
|
+
API_DETAILED = """┌── API Request ──┐
|
|
192
|
+
│ Time: {time}
|
|
193
|
+
│ Method: {method}
|
|
194
|
+
│ URL: {url}
|
|
195
|
+
├─────────────────
|
|
196
|
+
│ Status: {status_code}
|
|
197
|
+
│ {message}
|
|
198
|
+
└─────────────────"""
|
|
199
|
+
|
|
200
|
+
# System & Metrics
|
|
201
|
+
SYSTEM = """┌─── System Status ───┐
|
|
202
|
+
│ {time}
|
|
203
|
+
├───────────────────────
|
|
204
|
+
│ Component: {name}
|
|
205
|
+
│ Status: {level}
|
|
206
|
+
│ Message: {message}
|
|
207
|
+
└───────────────────────"""
|
|
208
|
+
|
|
209
|
+
METRIC = """┌── Metrics ──┐
|
|
210
|
+
│ Time: {time}
|
|
211
|
+
│ Value: {value}{units}
|
|
212
|
+
│ {message}
|
|
213
|
+
└─────────────"""
|
|
214
|
+
|
|
215
|
+
METRIC_COMPACT = "[METRIC] {name}={value} {units}"
|
|
216
|
+
METRIC_JSON = '{{"metric":"{name}","value":{value},"time":"{time}"}}'
|
|
217
|
+
|
|
218
|
+
# Security & Audit
|
|
219
|
+
SECURITY = """
|
|
220
|
+
Security Event
|
|
221
|
+
Time: {time}
|
|
222
|
+
Level: {level}
|
|
223
|
+
Source: {name}
|
|
224
|
+
Event: {message}"""
|
|
225
|
+
|
|
226
|
+
AUDIT = """
|
|
227
|
+
Audit Log Entry
|
|
228
|
+
Time: {time}
|
|
229
|
+
Level: {level}
|
|
230
|
+
Component: {name}
|
|
231
|
+
Action: {message}"""
|
|
232
|
+
|
|
233
|
+
SECURITY_ALERT = """╔═══ SECURITY ALERT ═══╗
|
|
234
|
+
║ Time: {time}
|
|
235
|
+
║ Level: {level}
|
|
236
|
+
║ Component: {name}
|
|
237
|
+
╟───────────────────────
|
|
238
|
+
║ {message}
|
|
239
|
+
╚═══════════════════════"""
|
|
240
|
+
|
|
241
|
+
# Special Formats
|
|
242
|
+
RAINBOW = " {time} {level} {message}"
|
|
243
|
+
MINIMAL_EMOJI = "{emoji} {message}"
|
|
244
|
+
TIMESTAMP = "{time} {message}"
|
|
245
|
+
COMPONENT = "[{name}] {message}"
|
|
246
|
+
HASH = "#{hash} | {time} | {message}"
|
|
247
|
+
TAG = "@{tag} | {time} | {message}"
|
|
248
|
+
|
|
249
|
+
# Data Formats
|
|
250
|
+
JSON = '{{"time":"{time}","level":"{level}","name":"{name}","message":"{message}"}}'
|
|
251
|
+
JSON_PRETTY = """{
|
|
252
|
+
"timestamp": "{time}",
|
|
253
|
+
"level": "{level}",
|
|
254
|
+
"component": "{name}",
|
|
255
|
+
"message": "{message}"
|
|
256
|
+
}"""
|
|
257
|
+
|
|
258
|
+
XML = """<log>
|
|
259
|
+
<time>{time}</time>
|
|
260
|
+
<level>{level}</level>
|
|
261
|
+
<name>{name}</name>
|
|
262
|
+
<message>{message}</message>
|
|
263
|
+
</log>"""
|
|
264
|
+
|
|
265
|
+
YAML = """---
|
|
266
|
+
timestamp: {time}
|
|
267
|
+
level: {level}
|
|
268
|
+
component: {name}
|
|
269
|
+
details:
|
|
270
|
+
message: {message}
|
|
271
|
+
"""
|
|
272
|
+
|
|
273
|
+
# Modern Documentation Formats
|
|
274
|
+
MARKDOWN = """## Log Entry
|
|
275
|
+
**Time:** `{time}`
|
|
276
|
+
**Level:** `{level}`
|
|
277
|
+
**Component:** `{name}`
|
|
278
|
+
|
|
279
|
+
> {message}
|
|
280
|
+
---"""
|
|
281
|
+
|
|
282
|
+
RST = """
|
|
283
|
+
Log Entry
|
|
284
|
+
=========
|
|
285
|
+
:Time: {time}
|
|
286
|
+
:Level: {level}
|
|
287
|
+
:Component: {name}
|
|
288
|
+
:Message: {message}
|
|
289
|
+
"""
|
|
290
|
+
|
|
291
|
+
HTML = """<div class="log-entry">
|
|
292
|
+
<div class="log-header">
|
|
293
|
+
<span class="time">{time}</span>
|
|
294
|
+
<span class="level">{level}</span>
|
|
295
|
+
</div>
|
|
296
|
+
<div class="log-body">
|
|
297
|
+
<span class="name">{name}</span>
|
|
298
|
+
<span class="message">{message}</span>
|
|
299
|
+
</div>
|
|
300
|
+
</div>"""
|
|
301
|
+
|
|
302
|
+
# Rich Console Formats
|
|
303
|
+
RICH = """╭── {name} ──╮
|
|
304
|
+
│ {time} │ {level_colored}
|
|
305
|
+
├──────────┴───────────
|
|
306
|
+
│ {message}
|
|
307
|
+
│ {context}{exception}
|
|
308
|
+
╰────────────────────"""
|
|
309
|
+
|
|
310
|
+
RICH_DETAILED = """╔══════════════════════════╗
|
|
311
|
+
║ {name}
|
|
312
|
+
╟──────────────────────────
|
|
313
|
+
║ Time: {time}
|
|
314
|
+
║ Level: {level_colored}
|
|
315
|
+
║ Thread: {thread_info}
|
|
316
|
+
╟──────────────────────────
|
|
317
|
+
║ {message}
|
|
318
|
+
║ {context}{exception}
|
|
319
|
+
╚══════════════════════════╝"""
|
|
320
|
+
|
|
321
|
+
RICH_MINIMAL = "│ {time} │ {level_colored} │ {message}"
|
|
322
|
+
|
|
323
|
+
RICH_COMPACT = "⟦{time}⟧ {level_colored} [{name}] ⟫ {message}"
|
|
324
|
+
|
|
325
|
+
# Template registry
|
|
326
|
+
TEMPLATES = {
|
|
327
|
+
# Basic formats
|
|
328
|
+
"minimal": MINIMAL,
|
|
329
|
+
"standard": STANDARD,
|
|
330
|
+
"detailed": DETAILED,
|
|
331
|
+
"simple": SIMPLE,
|
|
332
|
+
"compact": COMPACT,
|
|
333
|
+
|
|
334
|
+
# Modern styles
|
|
335
|
+
"modern": MODERN,
|
|
336
|
+
"modern_emoji": MODERN_EMOJI,
|
|
337
|
+
"modern_clean": MODERN_CLEAN,
|
|
338
|
+
"modern_bracket": MODERN_BRACKET,
|
|
339
|
+
"modern_plus": MODERN_PLUS,
|
|
340
|
+
"modern_dot": MODERN_DOT,
|
|
341
|
+
"modern_arrow": MODERN_ARROW,
|
|
342
|
+
|
|
343
|
+
# Boxed styles
|
|
344
|
+
"boxed": BOXED,
|
|
345
|
+
"double_box": DOUBLE_BOX,
|
|
346
|
+
"rounded_box": ROUNDED_BOX,
|
|
347
|
+
"rainbow_box": RAINBOW_BOX,
|
|
348
|
+
"heavy_box": HEAVY_BOX,
|
|
349
|
+
"dotted_box": DOTTED_BOX,
|
|
350
|
+
|
|
351
|
+
# Debug formats
|
|
352
|
+
"debug": DEBUG,
|
|
353
|
+
"debug_full": DEBUG_FULL,
|
|
354
|
+
"trace": TRACE,
|
|
355
|
+
"debug_compact": DEBUG_COMPACT,
|
|
356
|
+
"debug_extended": DEBUG_EXTENDED,
|
|
357
|
+
|
|
358
|
+
# Error formats
|
|
359
|
+
"error": ERROR,
|
|
360
|
+
"error_detailed": ERROR_DETAILED,
|
|
361
|
+
"error_compact": ERROR_COMPACT,
|
|
362
|
+
"error_emoji": ERROR_EMOJI,
|
|
363
|
+
"error_block": ERROR_BLOCK,
|
|
364
|
+
|
|
365
|
+
# Status formats
|
|
366
|
+
"status": STATUS,
|
|
367
|
+
"progress": PROGRESS,
|
|
368
|
+
"progress_simple": PROGRESS_SIMPLE,
|
|
369
|
+
"progress_bar": PROGRESS_BAR,
|
|
370
|
+
|
|
371
|
+
# Network formats
|
|
372
|
+
"http": HTTP,
|
|
373
|
+
"request": REQUEST,
|
|
374
|
+
"response": RESPONSE,
|
|
375
|
+
"api_compact": API_COMPACT,
|
|
376
|
+
"api_detailed": API_DETAILED,
|
|
377
|
+
|
|
378
|
+
# System formats
|
|
379
|
+
"system": SYSTEM,
|
|
380
|
+
"metric": METRIC,
|
|
381
|
+
"metric_compact": METRIC_COMPACT,
|
|
382
|
+
"metric_json": METRIC_JSON,
|
|
383
|
+
|
|
384
|
+
# Security formats
|
|
385
|
+
"security": SECURITY,
|
|
386
|
+
"audit": AUDIT,
|
|
387
|
+
"security_alert": SECURITY_ALERT,
|
|
388
|
+
|
|
389
|
+
# Special formats
|
|
390
|
+
"rainbow": RAINBOW,
|
|
391
|
+
"minimal_emoji": MINIMAL_EMOJI,
|
|
392
|
+
"timestamp": TIMESTAMP,
|
|
393
|
+
"component": COMPONENT,
|
|
394
|
+
"hash": HASH,
|
|
395
|
+
"tag": TAG,
|
|
396
|
+
|
|
397
|
+
# Data formats
|
|
398
|
+
"json": JSON,
|
|
399
|
+
"json_pretty": JSON_PRETTY,
|
|
400
|
+
"xml": XML,
|
|
401
|
+
"yaml": YAML,
|
|
402
|
+
|
|
403
|
+
# Documentation formats
|
|
404
|
+
"markdown": MARKDOWN,
|
|
405
|
+
"rst": RST,
|
|
406
|
+
"html": HTML,
|
|
407
|
+
|
|
408
|
+
# Rich-like formats
|
|
409
|
+
"rich": RICH,
|
|
410
|
+
"rich_detailed": RICH_DETAILED,
|
|
411
|
+
"rich_minimal": RICH_MINIMAL,
|
|
412
|
+
"rich_compact": RICH_COMPACT,
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
@staticmethod
|
|
416
|
+
def create_custom(template: str) -> str:
|
|
417
|
+
"""Create a custom log format template."""
|
|
418
|
+
try:
|
|
419
|
+
# Test if the template is valid by formatting with dummy data
|
|
420
|
+
dummy_data = {
|
|
421
|
+
"time": "2024-01-01 00:00:00",
|
|
422
|
+
"level": "INFO",
|
|
423
|
+
"name": "test",
|
|
424
|
+
"message": "test message",
|
|
425
|
+
"file": "test.py",
|
|
426
|
+
"line": 1,
|
|
427
|
+
"emoji": "✨",
|
|
428
|
+
"progress_bar": "==========",
|
|
429
|
+
"percentage": 100,
|
|
430
|
+
"method": "GET",
|
|
431
|
+
"url": "/test",
|
|
432
|
+
"status_code": 200,
|
|
433
|
+
"value": 42,
|
|
434
|
+
"units": "ms",
|
|
435
|
+
"hash": "abc123",
|
|
436
|
+
"tag": "test"
|
|
437
|
+
}
|
|
438
|
+
template.format(**dummy_data)
|
|
439
|
+
return template
|
|
440
|
+
except KeyError as e:
|
|
441
|
+
raise ValueError(f"Invalid format template. Missing key: {e}")
|
|
442
|
+
except Exception as e:
|
|
443
|
+
raise ValueError(f"Invalid format template: {e}")
|
|
444
|
+
|
|
445
|
+
@staticmethod
|
|
446
|
+
def get_format(format_name: str) -> str:
|
|
447
|
+
"""Get a predefined format template by name."""
|
|
448
|
+
if format_name in LogFormat.TEMPLATES:
|
|
449
|
+
return LogFormat.TEMPLATES[format_name]
|
|
450
|
+
raise ValueError(f"Unknown format: {format_name}")
|
|
451
|
+
|
|
452
|
+
@staticmethod
|
|
453
|
+
def register_template(name: str, template: str):
|
|
454
|
+
"""Register a new format template."""
|
|
455
|
+
if name in LogFormat.TEMPLATES:
|
|
456
|
+
raise ValueError(f"Format template '{name}' already exists")
|
|
457
|
+
|
|
458
|
+
# Validate template before registering
|
|
459
|
+
LogFormat.create_custom(template)
|
|
460
|
+
LogFormat.TEMPLATES[name] = template
|