advdbg 0.2.5__tar.gz → 0.2.7__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.
- {advdbg-0.2.5 → advdbg-0.2.7}/PKG-INFO +6 -7
- {advdbg-0.2.5 → advdbg-0.2.7}/README.md +5 -6
- advdbg-0.2.7/advdbg/__init__.py +24 -0
- advdbg-0.2.7/advdbg/core.py +292 -0
- advdbg-0.2.7/advdbg/exceptions.py +13 -0
- advdbg-0.2.7/advdbg/update.py +30 -0
- {advdbg-0.2.5 → advdbg-0.2.7}/advdbg.egg-info/PKG-INFO +6 -7
- {advdbg-0.2.5 → advdbg-0.2.7}/advdbg.egg-info/SOURCES.txt +2 -0
- {advdbg-0.2.5 → advdbg-0.2.7}/pyproject.toml +1 -1
- advdbg-0.2.5/advdbg/__init__.py +0 -18
- advdbg-0.2.5/advdbg/core.py +0 -222
- {advdbg-0.2.5 → advdbg-0.2.7}/LICENSE +0 -0
- {advdbg-0.2.5 → advdbg-0.2.7}/advdbg/analyze.py +0 -0
- {advdbg-0.2.5 → advdbg-0.2.7}/advdbg/colors.py +0 -0
- {advdbg-0.2.5 → advdbg-0.2.7}/advdbg.egg-info/dependency_links.txt +0 -0
- {advdbg-0.2.5 → advdbg-0.2.7}/advdbg.egg-info/top_level.txt +0 -0
- {advdbg-0.2.5 → advdbg-0.2.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: advdbg
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: Minimalist colorful debug logger
|
|
5
5
|
Author-email: Darkey <weplayok3@gmail.com>, WinFun <placeholder@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -40,7 +40,7 @@ Available types:
|
|
|
40
40
|
`SUCCESS`
|
|
41
41
|
|
|
42
42
|
Returns:
|
|
43
|
-
Info - title of your debug (01.07.2026, 06:34:53) Text to debug!
|
|
43
|
+
Info - title of your debug (01.07.2026, 06:34:53) | Text to debug!
|
|
44
44
|
|
|
45
45
|
Configure existing category:
|
|
46
46
|
dbgVar.cfg(title='REQUEST')
|
|
@@ -48,12 +48,11 @@ dbgVar.cfg(title='REQUEST')
|
|
|
48
48
|
BEFORE: title of your debug
|
|
49
49
|
AFTER: REQUEST
|
|
50
50
|
|
|
51
|
-
## Change Log: v0.2.
|
|
51
|
+
## Change Log: v0.2.7
|
|
52
52
|
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
- Added
|
|
56
|
-
- Fixed colors
|
|
53
|
+
- Added custom exceptions
|
|
54
|
+
- Added about() method
|
|
55
|
+
- Added checker for updates
|
|
57
56
|
|
|
58
57
|
## Requirements
|
|
59
58
|
|
|
@@ -25,7 +25,7 @@ Available types:
|
|
|
25
25
|
`SUCCESS`
|
|
26
26
|
|
|
27
27
|
Returns:
|
|
28
|
-
Info - title of your debug (01.07.2026, 06:34:53) Text to debug!
|
|
28
|
+
Info - title of your debug (01.07.2026, 06:34:53) | Text to debug!
|
|
29
29
|
|
|
30
30
|
Configure existing category:
|
|
31
31
|
dbgVar.cfg(title='REQUEST')
|
|
@@ -33,12 +33,11 @@ dbgVar.cfg(title='REQUEST')
|
|
|
33
33
|
BEFORE: title of your debug
|
|
34
34
|
AFTER: REQUEST
|
|
35
35
|
|
|
36
|
-
## Change Log: v0.2.
|
|
36
|
+
## Change Log: v0.2.7
|
|
37
37
|
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
- Added
|
|
41
|
-
- Fixed colors
|
|
38
|
+
- Added custom exceptions
|
|
39
|
+
- Added about() method
|
|
40
|
+
- Added checker for updates
|
|
42
41
|
|
|
43
42
|
## Requirements
|
|
44
43
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Welcome to Advanced Debug.
|
|
3
|
+
Licensed with MIT
|
|
4
|
+
|
|
5
|
+
Change Logs:
|
|
6
|
+
- Added .about()
|
|
7
|
+
- Added custom exception
|
|
8
|
+
- Added checker for updates
|
|
9
|
+
'''
|
|
10
|
+
|
|
11
|
+
__version__ = '0.2.7'
|
|
12
|
+
|
|
13
|
+
from .core import AdvDBG
|
|
14
|
+
|
|
15
|
+
from .analyze import Breakpoint
|
|
16
|
+
import requests
|
|
17
|
+
from .update import Update
|
|
18
|
+
|
|
19
|
+
__all__ = ['AdvDBG', 'Breakpoint']
|
|
20
|
+
if Update.check_for_updates() == "Not latest!":
|
|
21
|
+
print('Available new update\n{Colors.INFO}{Update.return_installed()} → {Update.return_latest()}')
|
|
22
|
+
|
|
23
|
+
# For easy access, you can create a default instance
|
|
24
|
+
DebuGGer = AdvDBG()
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Welcome to Advanced Debug.
|
|
3
|
+
Core module.
|
|
4
|
+
'''
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
import random
|
|
9
|
+
from typing import Dict, Any, Optional, List
|
|
10
|
+
import requests
|
|
11
|
+
|
|
12
|
+
from .update import Update
|
|
13
|
+
from .colors import Colors
|
|
14
|
+
from .exceptions import OutputListError
|
|
15
|
+
# class Colors:
|
|
16
|
+
# WARN = ""
|
|
17
|
+
# ERROR = ""
|
|
18
|
+
# INFO = ""
|
|
19
|
+
# SUCCESS = ""
|
|
20
|
+
|
|
21
|
+
listPhrases = ['Writting some lines.', "Don't forgot to define!", 'Waiting for your command.']
|
|
22
|
+
randomPhrase = random.choice(listPhrases)
|
|
23
|
+
|
|
24
|
+
class AdvDBG:
|
|
25
|
+
_category_store: Dict[str, Dict[str, Any]] = {}
|
|
26
|
+
_defined_categories: Dict[str, 'AdvDBG'] = {}
|
|
27
|
+
|
|
28
|
+
def __init__(self, title='Debug', activated=False, notify=False, output: Optional[List[str]] = None, legacy=False):
|
|
29
|
+
if isinstance(title, str) and isinstance(activated, bool) and isinstance(notify, bool):
|
|
30
|
+
self.title = title
|
|
31
|
+
self.activated = False
|
|
32
|
+
self._defed = False
|
|
33
|
+
self.notify = notify
|
|
34
|
+
self.output = output or ['console']
|
|
35
|
+
self.legacy = legacy
|
|
36
|
+
else:
|
|
37
|
+
raise ValueError('Some parameters do not match required types')
|
|
38
|
+
|
|
39
|
+
# Валидация output
|
|
40
|
+
self._validate_output(self.output)
|
|
41
|
+
|
|
42
|
+
if title not in self._category_store:
|
|
43
|
+
self._category_store[title] = {}
|
|
44
|
+
if title not in self._defined_categories:
|
|
45
|
+
self._defined_categories[title] = self
|
|
46
|
+
|
|
47
|
+
def _validate_output(self, output_list: List[str]) -> None:
|
|
48
|
+
"""Валидирует список output"""
|
|
49
|
+
if output_list is None:
|
|
50
|
+
return
|
|
51
|
+
|
|
52
|
+
# Проверка на допустимые значения
|
|
53
|
+
allowed = {'console', 'file'}
|
|
54
|
+
for output_type in output_list:
|
|
55
|
+
if output_type not in allowed:
|
|
56
|
+
print(f"{Colors.ERROR} Error - AdvDBG | Error when reading the output type: Detected disallowed output. Please use console or file.\033[0m")
|
|
57
|
+
raise OutputListError(f"Disallowed output type: {output_type}")
|
|
58
|
+
|
|
59
|
+
# Проверка на повторяющиеся значения
|
|
60
|
+
if len(output_list) != len(set(output_list)):
|
|
61
|
+
# Находим дубликаты
|
|
62
|
+
seen = set()
|
|
63
|
+
duplicates = set()
|
|
64
|
+
for item in output_list:
|
|
65
|
+
if item in seen:
|
|
66
|
+
duplicates.add(item)
|
|
67
|
+
else:
|
|
68
|
+
seen.add(item)
|
|
69
|
+
|
|
70
|
+
print(f"{Colors.ERROR} Error - AdvDBG | {len(duplicates)} repeating output types were found. Please, delete repeating types and try again.\033[0m")
|
|
71
|
+
raise OutputListError(f"Repeating output types: {', '.join(duplicates)}")
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def define(cls, title: str = 'Debug', activated: bool = True, notify: bool = False, output: Optional[List[str]] = None, legacy: bool = False):
|
|
75
|
+
'''Defines your debug category.
|
|
76
|
+
:param title: Title of your category
|
|
77
|
+
:param activated: Toggle availability of category
|
|
78
|
+
:param notify: Toggles notification if category is not activated
|
|
79
|
+
:param output: Where logger will save lines?
|
|
80
|
+
:param legacy: Use old style?'''
|
|
81
|
+
|
|
82
|
+
# Валидация перед созданием экземпляра
|
|
83
|
+
output = output or ['console']
|
|
84
|
+
|
|
85
|
+
# Проверка на допустимые значения
|
|
86
|
+
allowed = {'console', 'file'}
|
|
87
|
+
for output_type in output:
|
|
88
|
+
if output_type not in allowed:
|
|
89
|
+
print(f"{Colors.ERROR} Error - AdvDBG | Error when reading the output type: Detected disallowed output. Please use console or file.\033[0m")
|
|
90
|
+
raise ValueError(f"Disallowed output type: {output_type}")
|
|
91
|
+
|
|
92
|
+
# Проверка на повторяющиеся значения
|
|
93
|
+
if len(output) != len(set(output)):
|
|
94
|
+
# Находим дубликаты
|
|
95
|
+
seen = set()
|
|
96
|
+
duplicates = set()
|
|
97
|
+
for item in output:
|
|
98
|
+
if item in seen:
|
|
99
|
+
duplicates.add(item)
|
|
100
|
+
else:
|
|
101
|
+
seen.add(item)
|
|
102
|
+
|
|
103
|
+
print(f"{Colors.ERROR} Error - AdvDBG | {len(duplicates)} repeating output types were found. Please, delete repeating types and try again.\033[0m")
|
|
104
|
+
raise ValueError(f"Repeating output types: {', '.join(duplicates)}")
|
|
105
|
+
|
|
106
|
+
inst = cls(title, activated, notify, output, legacy)
|
|
107
|
+
inst.title = title
|
|
108
|
+
inst.activated = True
|
|
109
|
+
inst.notify = notify
|
|
110
|
+
inst.output = output
|
|
111
|
+
inst.legacy = legacy
|
|
112
|
+
inst._defed = True
|
|
113
|
+
|
|
114
|
+
cls._category_store[title] = {
|
|
115
|
+
'title': title,
|
|
116
|
+
'activated': activated,
|
|
117
|
+
'notify': notify,
|
|
118
|
+
'output': output,
|
|
119
|
+
'legacy': legacy,
|
|
120
|
+
'created_at': datetime.now()
|
|
121
|
+
}
|
|
122
|
+
cls._defined_categories[title] = inst
|
|
123
|
+
return inst
|
|
124
|
+
|
|
125
|
+
@classmethod
|
|
126
|
+
def get_category_settings(cls, category: str) -> Optional[Dict[str, Any]]:
|
|
127
|
+
if category in cls._category_store:
|
|
128
|
+
return cls._category_store[category].copy()
|
|
129
|
+
return None
|
|
130
|
+
|
|
131
|
+
@classmethod
|
|
132
|
+
def get_all_categories(cls) -> List[str]:
|
|
133
|
+
return list(cls._category_store.keys())
|
|
134
|
+
|
|
135
|
+
@classmethod
|
|
136
|
+
def export_all_data(cls) -> Dict[str, Any]:
|
|
137
|
+
return {
|
|
138
|
+
'categories': cls._category_store.copy(),
|
|
139
|
+
'total_categories': len(cls._category_store),
|
|
140
|
+
'export_timestamp': datetime.now().isoformat(),
|
|
141
|
+
'version': '1.0'
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
def _write_to_log(self, text, log_type='INFO'):
|
|
145
|
+
'''For-Module only method.'''
|
|
146
|
+
if not 'file' in self.output:
|
|
147
|
+
return
|
|
148
|
+
|
|
149
|
+
try:
|
|
150
|
+
# Creating logs directory relative to the current working directory
|
|
151
|
+
logs_dir = os.path.join(os.getcwd(), 'logs')
|
|
152
|
+
os.makedirs(logs_dir, exist_ok=True)
|
|
153
|
+
|
|
154
|
+
current_date = datetime.now().strftime("%d.%m.%Y")
|
|
155
|
+
filename = f"log_{current_date}.txt"
|
|
156
|
+
filepath = os.path.join(logs_dir, filename)
|
|
157
|
+
|
|
158
|
+
current_time = datetime.now().strftime("%H:%M:%S")
|
|
159
|
+
log_entry = f"{self.title} {current_time} | {text}\n"
|
|
160
|
+
|
|
161
|
+
file_exists = os.path.exists(filepath)
|
|
162
|
+
|
|
163
|
+
with open(filepath, 'a', encoding='utf-8') as f:
|
|
164
|
+
if not file_exists:
|
|
165
|
+
f.write(f"/// Advanced Debugger\n")
|
|
166
|
+
f.write(f"Category: {self.title}\n")
|
|
167
|
+
f.write(randomPhrase)
|
|
168
|
+
f.write("\n\n")
|
|
169
|
+
|
|
170
|
+
f.write(log_entry)
|
|
171
|
+
|
|
172
|
+
except Exception as e:
|
|
173
|
+
print(f"\033[33mWARNING\033[0m | Failed to write to log file: {e}")
|
|
174
|
+
|
|
175
|
+
def info(self, text):
|
|
176
|
+
"""Print debug information
|
|
177
|
+
Type: INFO
|
|
178
|
+
|
|
179
|
+
:param text: Text to show"""
|
|
180
|
+
if not isinstance(text, str):
|
|
181
|
+
try:
|
|
182
|
+
text = str(text)
|
|
183
|
+
except Exception as e:
|
|
184
|
+
text = f"Cannot convert to string format: {e}"
|
|
185
|
+
|
|
186
|
+
if self.activated:
|
|
187
|
+
if self.legacy and 'console' in self.output:
|
|
188
|
+
print(f'[\033[90mINFO \033[95m{self.title} at {datetime.now().strftime("%D, %H:%M:%S")}\033[0m] {text} \033[0m')
|
|
189
|
+
elif not self.legacy and 'console' in self.output:
|
|
190
|
+
print(f'{Colors.INFO} Info - {self.title} ({datetime.now().strftime("%D, %H:%M:%S")}) | {text}\033[0m')
|
|
191
|
+
if 'file' in self.output:
|
|
192
|
+
self._write_to_log(text, 'INFO')
|
|
193
|
+
elif self.notify:
|
|
194
|
+
print(f'Notification from {self.title}: Tried to output when disactivated.\n\033[93mTip: \033[0mIf you are did not want to saw these notifications, turn off NOTIFY property with using notify=False\033[0m')
|
|
195
|
+
else:
|
|
196
|
+
return
|
|
197
|
+
|
|
198
|
+
def warn(self, text):
|
|
199
|
+
if not isinstance(text, str):
|
|
200
|
+
try:
|
|
201
|
+
text = str(text)
|
|
202
|
+
except Exception as e:
|
|
203
|
+
text = f"Cannot convert to string format: {e}"
|
|
204
|
+
|
|
205
|
+
if self.activated:
|
|
206
|
+
if self.legacy and 'console' in self.output:
|
|
207
|
+
print(f'[\033[90mWARN \033[95m{self.title} at {datetime.now().strftime("%D, %H:%M:%S")}\033[0m] {text} \033[0m')
|
|
208
|
+
elif not self.legacy and 'console' in self.output:
|
|
209
|
+
print(f'{Colors.WARN} Warn - {self.title} ({datetime.now().strftime("%D, %H:%M:%S")}) | {text}\033[0m')
|
|
210
|
+
if 'file' in self.output:
|
|
211
|
+
self._write_to_log(text, 'WARN')
|
|
212
|
+
elif self.notify:
|
|
213
|
+
print(f'Notification from {self.title}: Tried to output when disactivated.\n\033[93mTip: \033[0mIf you are did not want to saw these notifications, turn off NOTIFY property with using notify=False')
|
|
214
|
+
else:
|
|
215
|
+
return
|
|
216
|
+
|
|
217
|
+
def success(self, text):
|
|
218
|
+
if not isinstance(text, str):
|
|
219
|
+
try:
|
|
220
|
+
text = str(text)
|
|
221
|
+
except Exception as e:
|
|
222
|
+
text = f"Cannot convert to string format: {e}"
|
|
223
|
+
|
|
224
|
+
if self.activated:
|
|
225
|
+
if self.legacy and 'console' in self.output:
|
|
226
|
+
print(f'[\033[90mSUCCESS \033[95m{self.title} at {datetime.now().strftime("%D, %H:%M:%S")}\033[0m] {text} \033[0m')
|
|
227
|
+
elif not self.legacy and 'console' in self.output:
|
|
228
|
+
print(f'{Colors.SUCCESS} Success - {self.title} ({datetime.now().strftime("%D, %H:%M:%S")}) | {text}\033[0m')
|
|
229
|
+
if 'file' in self.output:
|
|
230
|
+
self._write_to_log(text, 'SUCCESS')
|
|
231
|
+
elif self.notify:
|
|
232
|
+
print(f'Notification from {self.title}: Tried to output when disactivated.\n\033[93mTip: \033[0mIf you are did not want to saw these notifications, turn off NOTIFY property with using notify=False')
|
|
233
|
+
else:
|
|
234
|
+
return
|
|
235
|
+
|
|
236
|
+
def error(self, text):
|
|
237
|
+
if not isinstance(text, str):
|
|
238
|
+
try:
|
|
239
|
+
text = str(text)
|
|
240
|
+
except Exception as e:
|
|
241
|
+
text = f"Cannot convert to string format: {e}"
|
|
242
|
+
|
|
243
|
+
if self.activated:
|
|
244
|
+
if self.legacy:
|
|
245
|
+
print(f'[\033[33mERROR \033[95m{self.title} at {datetime.now().strftime("%D, %H:%M:%S")}\033[0m] {text} \033[0m')
|
|
246
|
+
elif not self.legacy:
|
|
247
|
+
print(f'{Colors.ERROR} Error - {self.title} ({datetime.now().strftime("%D, %H:%M:%S")}) | {text}\033[0m')
|
|
248
|
+
if 'file' in self.output:
|
|
249
|
+
self._write_to_log(text, 'ERROR')
|
|
250
|
+
elif self.notify:
|
|
251
|
+
print(f'Notification from {self.title}: Tried to output when disactivated.\n\033[93mTip: \033[0mIf you are did not want to saw these notifications, turn off NOTIFY property with using notify=False')
|
|
252
|
+
else:
|
|
253
|
+
return
|
|
254
|
+
|
|
255
|
+
def notification(self, text):
|
|
256
|
+
"""This type is deprecated."""
|
|
257
|
+
print('Type "Notification" is deprecated. Please, change it to another.')
|
|
258
|
+
|
|
259
|
+
def cfg(self, activated=None, title: str = 'Debug', notify: bool = True, output: Optional[List[str]] = None):
|
|
260
|
+
'''Configure existing category'''
|
|
261
|
+
output = output or ['console']
|
|
262
|
+
|
|
263
|
+
# Валидация нового output
|
|
264
|
+
self._validate_output(output)
|
|
265
|
+
|
|
266
|
+
if activated is not None:
|
|
267
|
+
self.activated = activated
|
|
268
|
+
if self.activated is False:
|
|
269
|
+
self.notify = notify
|
|
270
|
+
elif title is not None:
|
|
271
|
+
self.title = title
|
|
272
|
+
elif output is not None:
|
|
273
|
+
self.output = output
|
|
274
|
+
|
|
275
|
+
if self.title in self._category_store:
|
|
276
|
+
self._category_store[self.title]['activated'] = self.activated
|
|
277
|
+
self._category_store[self.title]["title"] = self.title
|
|
278
|
+
self._category_store[self.title]["output"] = self.output
|
|
279
|
+
|
|
280
|
+
return self
|
|
281
|
+
|
|
282
|
+
def about():
|
|
283
|
+
print(f'Advanced Debugger\nfrom Darkey Labs\n\nVersion v{Update.return_installed()}\nLicensed with MIT')
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def __call__(self, text):
|
|
287
|
+
if not isinstance(text, str):
|
|
288
|
+
try:
|
|
289
|
+
text = str(text)
|
|
290
|
+
except Exception as e:
|
|
291
|
+
text = f"Cannot convert to string format: {e}"
|
|
292
|
+
self.info(text)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import importlib.metadata
|
|
3
|
+
|
|
4
|
+
class Update:
|
|
5
|
+
"""Class for AdvDBG to interact with Update"""
|
|
6
|
+
def return_latest():
|
|
7
|
+
"""Get latest version of AdvDBG.
|
|
8
|
+
|
|
9
|
+
Returns:
|
|
10
|
+
Actual version from PyPi."""
|
|
11
|
+
url = 'https://pypi.org/pypi/advdbg/json'
|
|
12
|
+
response = requests.get(url)
|
|
13
|
+
response.raise_for_status()
|
|
14
|
+
|
|
15
|
+
data = response.json()
|
|
16
|
+
return data['info']['version']
|
|
17
|
+
|
|
18
|
+
def return_installed():
|
|
19
|
+
try:
|
|
20
|
+
return importlib.metadata.version('advdbg')
|
|
21
|
+
except importlib.metadata.PackageNotFoundError:
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
def check_for_updates():
|
|
25
|
+
if Update.return_installed() != Update.return_latest():
|
|
26
|
+
return f"Not latest!"
|
|
27
|
+
|
|
28
|
+
return "Latest"
|
|
29
|
+
|
|
30
|
+
print(Update.check_for_updates())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: advdbg
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: Minimalist colorful debug logger
|
|
5
5
|
Author-email: Darkey <weplayok3@gmail.com>, WinFun <placeholder@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -40,7 +40,7 @@ Available types:
|
|
|
40
40
|
`SUCCESS`
|
|
41
41
|
|
|
42
42
|
Returns:
|
|
43
|
-
Info - title of your debug (01.07.2026, 06:34:53) Text to debug!
|
|
43
|
+
Info - title of your debug (01.07.2026, 06:34:53) | Text to debug!
|
|
44
44
|
|
|
45
45
|
Configure existing category:
|
|
46
46
|
dbgVar.cfg(title='REQUEST')
|
|
@@ -48,12 +48,11 @@ dbgVar.cfg(title='REQUEST')
|
|
|
48
48
|
BEFORE: title of your debug
|
|
49
49
|
AFTER: REQUEST
|
|
50
50
|
|
|
51
|
-
## Change Log: v0.2.
|
|
51
|
+
## Change Log: v0.2.7
|
|
52
52
|
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
- Added
|
|
56
|
-
- Fixed colors
|
|
53
|
+
- Added custom exceptions
|
|
54
|
+
- Added about() method
|
|
55
|
+
- Added checker for updates
|
|
57
56
|
|
|
58
57
|
## Requirements
|
|
59
58
|
|
advdbg-0.2.5/advdbg/__init__.py
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'''
|
|
2
|
-
Welcome to Advanced Debug.
|
|
3
|
-
Licensed with MIT
|
|
4
|
-
|
|
5
|
-
Change Logs:
|
|
6
|
-
- Hotfix 0.2.3
|
|
7
|
-
'''
|
|
8
|
-
|
|
9
|
-
__version__ = '0.2.4'
|
|
10
|
-
|
|
11
|
-
from .core import AdvDBG
|
|
12
|
-
|
|
13
|
-
from .analyze import Breakpoint
|
|
14
|
-
|
|
15
|
-
__all__ = ['AdvDBG', 'Breakpoint']
|
|
16
|
-
|
|
17
|
-
# For easy access, you can create a default instance
|
|
18
|
-
DebuGGer = AdvDBG()
|
advdbg-0.2.5/advdbg/core.py
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
'''
|
|
2
|
-
Welcome to Advanced Debug.
|
|
3
|
-
Core module.
|
|
4
|
-
'''
|
|
5
|
-
|
|
6
|
-
import os
|
|
7
|
-
from datetime import datetime
|
|
8
|
-
import random
|
|
9
|
-
from typing import Dict, Any, Optional, List
|
|
10
|
-
|
|
11
|
-
from .colors import Colors
|
|
12
|
-
|
|
13
|
-
listPhrases = ['Writting some lines.', "Don't forgot to define!", 'Waiting for your command.']
|
|
14
|
-
randomPhrase = random.choice(listPhrases)
|
|
15
|
-
|
|
16
|
-
class AdvDBG:
|
|
17
|
-
_category_store: Dict[str, Dict[str, Any]] = {}
|
|
18
|
-
_defined_categories: Dict[str, 'AdvDBG'] = {}
|
|
19
|
-
|
|
20
|
-
def __init__(self, title='Debug', activated=False, notify=False, output: Optional[list[str]] = ['console'], legacy=False) -> List[str]:
|
|
21
|
-
if isinstance(title, str) and isinstance(activated, bool) and isinstance(notify, bool):
|
|
22
|
-
self.title = title
|
|
23
|
-
self.activated = False
|
|
24
|
-
self._defed = False
|
|
25
|
-
self.notify = notify
|
|
26
|
-
self.output = output
|
|
27
|
-
self.legacy = legacy
|
|
28
|
-
else:
|
|
29
|
-
raise ValueError('Some parameters do not match required types')
|
|
30
|
-
|
|
31
|
-
if title not in self._category_store:
|
|
32
|
-
self._category_store[title] = {}
|
|
33
|
-
if title not in self._defined_categories:
|
|
34
|
-
self._defined_categories[title] = self
|
|
35
|
-
|
|
36
|
-
@classmethod
|
|
37
|
-
def define(cls, title: str = 'Debug', activated: bool = True, notify: bool = False, output: Optional[list[str]] = ['console'], legacy: bool = False) -> List[str]:
|
|
38
|
-
'''Defines your debug category.
|
|
39
|
-
:param title: Title of your category
|
|
40
|
-
:param activated: Toggle availability of category
|
|
41
|
-
:param notify: Toggles notification if category is not activated
|
|
42
|
-
:param output: Where logger will save lines?
|
|
43
|
-
:param legacy: Use old style?'''
|
|
44
|
-
inst = cls(title, activated, notify, output, legacy)
|
|
45
|
-
inst.title = title
|
|
46
|
-
inst.activated = True
|
|
47
|
-
inst.notify = notify
|
|
48
|
-
inst.output = output
|
|
49
|
-
inst.legacy = legacy
|
|
50
|
-
inst._defed = True
|
|
51
|
-
|
|
52
|
-
cls._category_store[title] = {
|
|
53
|
-
'title': title,
|
|
54
|
-
'activated': activated,
|
|
55
|
-
'notify': notify,
|
|
56
|
-
'output': output,
|
|
57
|
-
'legacy': legacy,
|
|
58
|
-
'created_at': datetime.now()
|
|
59
|
-
}
|
|
60
|
-
cls._defined_categories[title] = inst
|
|
61
|
-
return inst
|
|
62
|
-
|
|
63
|
-
@classmethod
|
|
64
|
-
def get_category_settings(cls, category: str) -> Optional[Dict[str, Any]]:
|
|
65
|
-
if category in cls._category_store:
|
|
66
|
-
return cls._category_store[category].copy()
|
|
67
|
-
return None
|
|
68
|
-
|
|
69
|
-
@classmethod
|
|
70
|
-
def get_all_categories(cls) -> List[str]:
|
|
71
|
-
return list(cls._category_store.keys())
|
|
72
|
-
|
|
73
|
-
@classmethod
|
|
74
|
-
def export_all_data(cls) -> Dict[str, Any]:
|
|
75
|
-
return {
|
|
76
|
-
'categories': cls._category_store.copy(),
|
|
77
|
-
'total_categories': len(cls._category_store),
|
|
78
|
-
'export_timestamp': datetime.now().isoformat(),
|
|
79
|
-
'version': '1.0'
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
def _write_to_log(self, text, log_type='INFO'):
|
|
83
|
-
'''For-Module only method.'''
|
|
84
|
-
if not 'file' in self.output:
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
try:
|
|
88
|
-
# Creating logs directory relative to the current working directory
|
|
89
|
-
logs_dir = os.path.join(os.getcwd(), 'logs')
|
|
90
|
-
os.makedirs(logs_dir, exist_ok=True)
|
|
91
|
-
|
|
92
|
-
current_date = datetime.now().strftime("%d.%m.%Y")
|
|
93
|
-
filename = f"log_{current_date}.txt"
|
|
94
|
-
filepath = os.path.join(logs_dir, filename)
|
|
95
|
-
|
|
96
|
-
current_time = datetime.now().strftime("%H:%M:%S")
|
|
97
|
-
log_entry = f"{self.title} {current_time} | {text}\n"
|
|
98
|
-
|
|
99
|
-
file_exists = os.path.exists(filepath)
|
|
100
|
-
|
|
101
|
-
with open(filepath, 'a', encoding='utf-8') as f:
|
|
102
|
-
if not file_exists:
|
|
103
|
-
f.write(f"/// Advanced Debugger\n")
|
|
104
|
-
f.write(f"Category: {self.title}\n")
|
|
105
|
-
f.write(randomPhrase)
|
|
106
|
-
f.write("\n\n")
|
|
107
|
-
|
|
108
|
-
f.write(log_entry)
|
|
109
|
-
|
|
110
|
-
except Exception as e:
|
|
111
|
-
print(f"\033[33mWARNING\033[0m | Failed to write to log file: {e}")
|
|
112
|
-
|
|
113
|
-
def info(self, text):
|
|
114
|
-
"""Print debug information
|
|
115
|
-
Type: INFO
|
|
116
|
-
|
|
117
|
-
:param text: Text to show"""
|
|
118
|
-
if not isinstance(text, str):
|
|
119
|
-
try:
|
|
120
|
-
text = str(text)
|
|
121
|
-
except Exception as e:
|
|
122
|
-
text = f"Cannot convert to string format: {e}"
|
|
123
|
-
|
|
124
|
-
if self.activated:
|
|
125
|
-
if self.legacy and 'console' in self.output:
|
|
126
|
-
print(f'[\033[90mINFO \033[95m{self.title} at {datetime.now().strftime("%D, %H:%M:%S")}\033[0m] {text} \033[0m')
|
|
127
|
-
elif not self.legacy and 'console' in self.output:
|
|
128
|
-
print(f'{Colors.INFO} Info - {self.title} ({datetime.now().strftime("%D, %H:%M:%S")}) | {text}\033[0m')
|
|
129
|
-
if 'file' in self.output:
|
|
130
|
-
self._write_to_log(text, 'INFO')
|
|
131
|
-
elif self.notify:
|
|
132
|
-
print(f'Notification from {self.title}: Tried to output when disactivated.\n\033[93mTip: \033[0mIf you are did not want to saw these notifications, turn off NOTIFY property with using notify=False\033[0m')
|
|
133
|
-
else:
|
|
134
|
-
return
|
|
135
|
-
|
|
136
|
-
def warn(self, text):
|
|
137
|
-
if not isinstance(text, str):
|
|
138
|
-
try:
|
|
139
|
-
text = str(text)
|
|
140
|
-
except Exception as e:
|
|
141
|
-
text = f"Cannot convert to string format: {e}"
|
|
142
|
-
|
|
143
|
-
if self.activated:
|
|
144
|
-
if self.legacy and 'console' in self.output:
|
|
145
|
-
print(f'[\033[90mWARN \033[95m{self.title} at {datetime.now().strftime("%D, %H:%M:%S")}\033[0m] {text} \033[0m')
|
|
146
|
-
elif not self.legacy and 'console' in self.output:
|
|
147
|
-
print(f'{Colors.WARN} Warn - {self.title} ({datetime.now().strftime("%D, %H:%M:%S")}) | {text}\033[0m')
|
|
148
|
-
if 'file' in self.output:
|
|
149
|
-
self._write_to_log(text, 'WARN')
|
|
150
|
-
elif self.notify:
|
|
151
|
-
print(f'Notification from {self.title}: Tried to output when disactivated.\n\033[93mTip: \033[0mIf you are did not want to saw these notifications, turn off NOTIFY property with using notify=False')
|
|
152
|
-
else:
|
|
153
|
-
return
|
|
154
|
-
|
|
155
|
-
def success(self, text):
|
|
156
|
-
if not isinstance(text, str):
|
|
157
|
-
try:
|
|
158
|
-
text = str(text)
|
|
159
|
-
except Exception as e:
|
|
160
|
-
text = f"Cannot convert to string format: {e}"
|
|
161
|
-
|
|
162
|
-
if self.activated:
|
|
163
|
-
if self.legacy and 'console' in self.output:
|
|
164
|
-
print(f'[\033[90mSUCCESS \033[95m{self.title} at {datetime.now().strftime("%D, %H:%M:%S")}\033[0m] {text} \033[0m')
|
|
165
|
-
elif not self.legacy and 'console' in self.output:
|
|
166
|
-
print(f'{Colors.SUCCESS} Success - {self.title} ({datetime.now().strftime("%D, %H:%M:%S")}) | {text}\033[0m')
|
|
167
|
-
if 'file' in self.output:
|
|
168
|
-
self._write_to_log(text, 'SUCCESS')
|
|
169
|
-
elif self.notify:
|
|
170
|
-
print(f'Notification from {self.title}: Tried to output when disactivated.\n\033[93mTip: \033[0mIf you are did not want to saw these notifications, turn off NOTIFY property with using notify=False')
|
|
171
|
-
else:
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
def error(self, text):
|
|
176
|
-
if not isinstance(text, str):
|
|
177
|
-
try:
|
|
178
|
-
text = str(text)
|
|
179
|
-
except Exception as e:
|
|
180
|
-
text = f"Cannot convert to string format: {e}"
|
|
181
|
-
|
|
182
|
-
if self.activated:
|
|
183
|
-
if self.legacy:
|
|
184
|
-
print(f'[\033[33mERROR \033[95m{self.title} at {datetime.now().strftime("%D, %H:%M:%S")}\033[0m] {text} \033[0m')
|
|
185
|
-
elif not self.legacy:
|
|
186
|
-
print(f'{Colors.ERROR} Error - {self.title} ({datetime.now().strftime("%D, %H:%M:%S")}) | {text}\033[0m')
|
|
187
|
-
if 'file' in self.output:
|
|
188
|
-
self._write_to_log(text, 'ERROR')
|
|
189
|
-
elif self.notify:
|
|
190
|
-
print(f'Notification from {self.title}: Tried to output when disactivated.\n\033[93mTip: \033[0mIf you are did not want to saw these notifications, turn off NOTIFY property with using notify=False')
|
|
191
|
-
else:
|
|
192
|
-
return
|
|
193
|
-
|
|
194
|
-
def notification(self, text):
|
|
195
|
-
"""This type is deprecated."""
|
|
196
|
-
print('Type "Notification" is deprecated. Please, change it to another.')
|
|
197
|
-
|
|
198
|
-
def cfg(self, activated=None, title: str = 'Debug', notify: bool = True, output: Optional[List[str]] = ['output']):
|
|
199
|
-
'''Configure existing category'''
|
|
200
|
-
if activated is not None:
|
|
201
|
-
self.activated = activated
|
|
202
|
-
if self.activated is False:
|
|
203
|
-
self.notify = notify
|
|
204
|
-
elif title is not None:
|
|
205
|
-
self.title = title
|
|
206
|
-
elif output is not None:
|
|
207
|
-
self.output = output
|
|
208
|
-
|
|
209
|
-
if self.title in self._category_store:
|
|
210
|
-
self._category_store[self.title]['activated'] = self.activated
|
|
211
|
-
self._category_store[self.title]["title"] = self.title
|
|
212
|
-
self._category_store[self.title]["output"] = self.output
|
|
213
|
-
|
|
214
|
-
return self
|
|
215
|
-
|
|
216
|
-
def __call__(self, text):
|
|
217
|
-
if not isinstance(text, str):
|
|
218
|
-
try:
|
|
219
|
-
text = str(text)
|
|
220
|
-
except Exception as e:
|
|
221
|
-
text = f"Cannot convert to string format: {e}"
|
|
222
|
-
self.info(text)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|