For development/debugging diagnostics.
( text='', caller=1)
| 241 | ) |
| 242 | |
| 243 | def log( text='', caller=1): |
| 244 | ''' |
| 245 | For development/debugging diagnostics. |
| 246 | ''' |
| 247 | try: |
| 248 | stack = inspect.stack(context=0) |
| 249 | except StopIteration: |
| 250 | pass |
| 251 | else: |
| 252 | frame_record = stack[caller] |
| 253 | try: |
| 254 | filename = os.path.relpath(frame_record.filename) |
| 255 | except Exception: # Can fail on windows. |
| 256 | filename = frame_record.filename |
| 257 | line = frame_record.lineno |
| 258 | function = frame_record.function |
| 259 | text = f'{filename}:{line}:{function}(): {text}' |
| 260 | if _g_log_items_active: |
| 261 | _g_log_items.append(text) |
| 262 | if _g_out_log: |
| 263 | print(text, file=_g_out_log, flush=1) |
| 264 | |
| 265 | |
| 266 | def message(text=''): |