27 from ..
import context
28 from ..
import widgets
29 from ..pluginapi
import Plugin
30 from ..action
import ActionInfo
31 from ..publish.messages
import RideLog
32 from ..widgets
import RIDEDialog
36 return '%s [%s]: %s\n\n' % (msg.timestamp, msg.level, msg.message)
43 Plugin.__init__(self, app, default_settings={
44 'log_to_console':
False,
50 tempfile.gettempdir(),
'{}-ride.log'.format(uuid.uuid4()))
53 atexit.register(self.
_close_close)
56 if self.
_outfile_outfile
is not None:
60 for fname
in glob.glob(
61 os.path.join(tempfile.gettempdir(),
'*-ride.log')):
64 except OSError
or IOError
or PermissionError
as e:
65 sys.stderr.write(f
"Removing old *-ride.log files failed with: {repr(e)}\n")
74 self.
_outfile_outfile = io.open(self.
_path_path,
'w', encoding=
'utf8')
82 self.unsubscribe_all()
83 self.unregister_actions()
85 self.
_panel_panel.close(self.notebook)
88 self.unregister_actions()
90 'Tools',
'View RIDE Log', self.
OnViewLogOnViewLog, position=84))
93 self.
_log_log.append(message)
95 self.
_panel_panel.update_log()
96 if self.log_to_console:
101 if message.notify_user:
102 font_size = 13
if context.IS_MAC
else -1
104 padding=10, font_size=font_size).Show()
109 self.
_panel_panel.update_log()
110 self.register_shortcut(
'CtrlCmd-C',
lambda e: self.
_panel_panel.Copy())
112 self.notebook.show_tab(self.
_panel_panel)
118 wx.Panel.__init__(self, notebook)
119 self.
dlgdlg = RIDEDialog()
120 self.
_output_output = wx.TextCtrl(self, style=wx.TE_READONLY | wx.TE_MULTILINE | wx.TE_NOHIDESEL)
121 self.
_output_output.SetBackgroundColour(Colour(self.
dlgdlg.color_background))
122 self.
_output_output.SetForegroundColour(Colour(self.
dlgdlg.color_foreground))
127 self.Bind(wx.EVT_SIZE, self.
OnSizeOnSize)
131 self.Sizer.add_expanding(self.
_output_output)
134 notebook.add_tab(self,
'RIDE Log', allow_closing=
True)
135 notebook.show_tab(self)
136 self.
_output_output.SetSize(self.Size)
139 notebook.delete_tab(self)
151 self.
_output_output.SetSize(self.Size)
154 keycode = event.GetKeyCode()
156 if event.ControlDown()
and keycode == ord(
'A'):
165 self._output.SetSelection(-1, -1)
Used to create menu entries, keyboard shortcuts and/or toolbar buttons.
Viewer for internal log messages.
def _remove_old_log_files(self)
def OnViewLog(self, event)
def _log_message(self, message)
def _add_to_notebook(self, notebook)
def _decode_log(self, log)
def OnKeyDown(self, event)
def close(self, notebook)
def __init__(self, notebook, log)
def write(msg, level='INFO', html=False)
Writes the message to the log file using the given level.
def _message_to_string(msg)