mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
4ea27ae7da
changed print_exec to print in both console and fishy fixed engine couldn't be stoped with toggle fixed full auto stop getting called multiple times due to inactive stop set logging for d3dshot to info, to remove debug logs caused by it
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import logging
|
|
import typing
|
|
from logging import StreamHandler, Formatter
|
|
|
|
if typing.TYPE_CHECKING:
|
|
from . import GUI
|
|
|
|
|
|
class GUIStreamHandler(StreamHandler):
|
|
def __init__(self, gui):
|
|
StreamHandler.__init__(self)
|
|
self.gui = gui
|
|
|
|
def emit(self, record):
|
|
# todo implement verbose/debug option to show more info
|
|
# formatter = Formatter('%(name)s - %(levelname)s - %(message)s')
|
|
# self.setFormatter(formatter)
|
|
msg = self.format(record)
|
|
self.gui.call_in_thread(lambda: _write_to_console(self.gui, msg))
|
|
|
|
|
|
def _write_to_console(root: 'GUI', msg):
|
|
numlines = root._console.index('end - 1 line').split('.')[0]
|
|
root._console['state'] = 'normal'
|
|
if int(numlines) >= 50: # delete old lines
|
|
root._console.delete(1.0, 2.0)
|
|
if root._console.index('end-1c') != '1.0': # new line for each log
|
|
root._console.insert('end', '\n')
|
|
root._console.insert('end', msg)
|
|
root._console.see("end") # scroll to bottom
|
|
root._console['state'] = 'disabled'
|