def _put_log() -> None: try: sessionname = str(_ba.get_foreground_host_session()) except Exception: sessionname = 'unavailable' try: activityname = str(_ba.get_foreground_host_activity()) except Exception: activityname = 'unavailable' info = { 'log': _ba.getlog(), 'version': app.version, 'build': app.build_number, 'userAgentString': app.user_agent_string, 'session': sessionname, 'activity': activityname, 'fatal': 0, 'userRanCommands': _ba.has_user_run_commands(), 'time': _ba.time(TimeType.REAL), 'userModded': _ba.has_user_mods(), 'newsShow': _ba.get_news_show(), } def response(data: Any) -> None: # A non-None response means success; lets # take note that we don't need to report further # log info this run if data is not None: app.log_have_new = False _ba.mark_log_sent() master_server_post('bsLog', info, response)
def run(self) -> None: f = open_log() log = '' while True: log_ = _ba.getlog() if log_ != log: log = log_ try: f.write(log) f.flush() except Exception as exc: f = open_log() f.write(str(exc)) f.flush() time.sleep(1.0)
def run() -> None: log = '' while True: _log = _ba.getlog() if log != _log: f = self.file if not f: break try: f.write(f'\n\nUPDATE-LOG:\n{_log}') except Exception as exc: print('File write exc', exc) self._file = None continue else: log = _log f.flush() time.sleep(self.coffee_break)