@@ -68,11 +68,47 @@ def IEH(id: str = 'Unknown', stop: bool = True, DEV: bool = True):
6868 traceback .print_exc ()
6969 if stop : sys .exit ('SYS EXIT|ERROR: Internal|by Internal Error Handler' )
7070#Debug
71- def Debug (ID , DEBUG_IF , SFL : bool = True ):
72- if Debug_m :
73- frame_info = inspect .currentframe ()
74- location = f'{ inspect .stack ()[1 ].filename } :{ frame_info .f_back .f_lineno } ' if SFL else f'L:{ frame_info .f_back .f_lineno } '
75- print_Color (f'\n ~*--> ~*DEBUG INFO id: ~*[{ str (ID )} ]~*, Location: ~*[{ location } ]~*, time: ~*[{ datetime .now ().strftime ("%Y/%m/%d | %H:%M:%S" )} ]\n ~*--> ~*Data: ~*{ str (DEBUG_IF )} \n ' , ['red' , 'magenta' , 'yellow' , 'magenta' , 'yellow' , 'magenta' , 'yellow' , 'red' , 'magenta' , 'yellow' ], advanced_mode = True )
71+ def Debug (ID , DEBUG_IF , SFL : bool = True , Force : bool = False , SFCS : bool = True ):
72+ """
73+ This function is used for debugging purposes. It prints out various information about the data passed to it.
74+
75+ Args:
76+ ID (Any): The identifier for the data. This could be any type, but is typically a string.
77+ DEBUG_IF (Any): The data that needs to be debugged. This could be any type.
78+ SFL (bool, optional): A flag to determine if the stack frame location should be included in the debug information. Defaults to True.
79+ Force (bool, optional): A flag to force the debug information to be printed even if the global Debug_m is set to False. Defaults to False.
80+ SFCS (bool, optional): A flag to determine if the function call stack should be included in the debug information. Defaults to True.
81+
82+ Returns:
83+ None
84+ """
85+ try :
86+ if Debug_m or Force :
87+ frame_info = inspect .currentframe ()
88+ stack_trace = traceback .format_stack ()
89+ stack_trace_formated = ''
90+ for line in stack_trace [:- 1 ]:
91+ stack_trace_formated += '--> [!>>>' + line
92+ location = f'{ inspect .stack ()[1 ].filename } :{ frame_info .f_back .f_lineno } ' if SFL else f'L:{ frame_info .f_back .f_lineno } '
93+ Debug_data = \
94+ f'\n ~*--> ~*DEBUG INFO id: ~*[{ str (ID )} ]~*, ' \
95+ f'Location: ~*[{ location } ]~*, ' \
96+ f'time: ~*[{ datetime .now ().strftime ("%Y/%m/%d | %H:%M:%S" )} ]\n ~*--> ~*' \
97+ f'Data: ~*{ str (DEBUG_IF )} \n ~*--> ~*' \
98+ f'Data Type: ~*{ type (DEBUG_IF )} \n ~*--> ~*' \
99+ f'Memory Address: ~*DEC>>>~*{ id (DEBUG_IF )} ~* | HEX>>>~*{ hex (id (DEBUG_IF ))} ~* | BIN>>>~*{ bin (id (DEBUG_IF ))} \n '
100+ if SFCS :
101+ Debug_data += f'~*--> ~*Function Call Stack: ~*↓\n ~*{ stack_trace_formated } \n '
102+ print_Color (Debug_data ,
103+ ['red' , 'magenta' , 'green' , 'magenta' , 'yellow' , 'magenta' , 'yellow' ,
104+ 'red' , 'magenta' , 'yellow' , 'red' , 'magenta' , 'yellow' , 'red' , 'magenta' ,
105+ 'cyan' , 'yellow' , 'cyan' , 'yellow' , 'cyan' , 'yellow' , 'red' , 'magenta' , 'green' , 'yellow' ] if SFCS else \
106+ ['red' , 'magenta' , 'green' , 'magenta' , 'yellow' , 'magenta' , 'yellow' ,
107+ 'red' , 'magenta' , 'yellow' , 'red' , 'magenta' , 'yellow' , 'red' , 'magenta' ,
108+ 'cyan' , 'yellow' , 'cyan' , 'yellow' , 'cyan' , 'yellow' ],
109+ advanced_mode = True )
110+ except NameError :
111+ print_Color ('~*[`Debug` func] --> ERROR: ~*carate a global var named `Debug_m` for turning on and off the Debug func.' , ['red' , 'yellow' ], advanced_mode = True )
76112#load modules
77113def LCM ():
78114 #Get Import List
0 commit comments