mirror of https://github.com/Desuuuu/klipper.git
klippy: Automatically clear rollover_info on each restart
Automatically clear the information printed at the start of each log file rollover on a klippy internal restart. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
a301713361
commit
bb8926d67a
|
@ -52,10 +52,16 @@ class KeyboardReader:
|
||||||
self.output(help_txt)
|
self.output(help_txt)
|
||||||
self.output("="*20 + " attempting to connect " + "="*20)
|
self.output("="*20 + " attempting to connect " + "="*20)
|
||||||
self.ser.connect()
|
self.ser.connect()
|
||||||
|
msgparser = self.ser.msgparser
|
||||||
|
self.output("Loaded %d commands (%s / %s)" % (
|
||||||
|
len(msgparser.messages_by_id),
|
||||||
|
msgparser.version, msgparser.build_versions))
|
||||||
|
self.output("MCU config: %s" % (" ".join(
|
||||||
|
["%s=%s" % (k, v) for k, v in msgparser.config.items()])))
|
||||||
self.clocksync.connect(self.ser)
|
self.clocksync.connect(self.ser)
|
||||||
self.ser.handle_default = self.handle_default
|
self.ser.handle_default = self.handle_default
|
||||||
self.mcu_freq = self.ser.msgparser.get_constant_float('CLOCK_FREQ')
|
self.mcu_freq = msgparser.get_constant_float('CLOCK_FREQ')
|
||||||
mcu_type = self.ser.msgparser.get_constant('MCU')
|
mcu_type = msgparser.get_constant('MCU')
|
||||||
self.pins = pins.PinResolver(mcu_type, validate_aliases=False)
|
self.pins = pins.PinResolver(mcu_type, validate_aliases=False)
|
||||||
self.reactor.unregister_timer(self.connect_timer)
|
self.reactor.unregister_timer(self.connect_timer)
|
||||||
self.output("="*20 + " connected " + "="*20)
|
self.output("="*20 + " connected " + "="*20)
|
||||||
|
|
|
@ -131,8 +131,6 @@ class Printer:
|
||||||
def __init__(self, input_fd, bglogger, start_args):
|
def __init__(self, input_fd, bglogger, start_args):
|
||||||
self.bglogger = bglogger
|
self.bglogger = bglogger
|
||||||
self.start_args = start_args
|
self.start_args = start_args
|
||||||
if bglogger is not None:
|
|
||||||
bglogger.set_rollover_info("config", None)
|
|
||||||
self.reactor = reactor.Reactor()
|
self.reactor = reactor.Reactor()
|
||||||
gc = gcode.GCodeParser(self, input_fd)
|
gc = gcode.GCodeParser(self, input_fd)
|
||||||
self.objects = collections.OrderedDict({'gcode': gc})
|
self.objects = collections.OrderedDict({'gcode': gc})
|
||||||
|
@ -170,6 +168,7 @@ class Printer:
|
||||||
return [self.objects[module_name]] + objs
|
return [self.objects[module_name]] + objs
|
||||||
return objs
|
return objs
|
||||||
def set_rollover_info(self, name, info):
|
def set_rollover_info(self, name, info):
|
||||||
|
logging.info(info)
|
||||||
if self.bglogger is not None:
|
if self.bglogger is not None:
|
||||||
self.bglogger.set_rollover_info(name, info)
|
self.bglogger.set_rollover_info(name, info)
|
||||||
def _stats(self, eventtime, force_output=False):
|
def _stats(self, eventtime, force_output=False):
|
||||||
|
@ -355,16 +354,18 @@ def main():
|
||||||
logging.info("Starting Klippy...")
|
logging.info("Starting Klippy...")
|
||||||
start_args['software_version'] = util.get_git_version()
|
start_args['software_version'] = util.get_git_version()
|
||||||
if bglogger is not None:
|
if bglogger is not None:
|
||||||
lines = ["Args: %s" % (sys.argv,),
|
versions = "\n".join([
|
||||||
|
"Args: %s" % (sys.argv,),
|
||||||
"Git version: %s" % (repr(start_args['software_version']),),
|
"Git version: %s" % (repr(start_args['software_version']),),
|
||||||
"CPU: %s" % (util.get_cpu_info(),),
|
"CPU: %s" % (util.get_cpu_info(),),
|
||||||
"Python: %s" % (repr(sys.version),)]
|
"Python: %s" % (repr(sys.version),)])
|
||||||
lines = "\n".join(lines)
|
logging.info(versions)
|
||||||
logging.info(lines)
|
|
||||||
bglogger.set_rollover_info('versions', lines)
|
|
||||||
|
|
||||||
# Start Printer() class
|
# Start Printer() class
|
||||||
while 1:
|
while 1:
|
||||||
|
if bglogger is not None:
|
||||||
|
bglogger.clear_rollover_info()
|
||||||
|
bglogger.set_rollover_info('versions', versions)
|
||||||
printer = Printer(input_fd, bglogger, start_args)
|
printer = Printer(input_fd, bglogger, start_args)
|
||||||
res = printer.run()
|
res = printer.run()
|
||||||
if res == 'exit':
|
if res == 'exit':
|
||||||
|
|
|
@ -424,7 +424,6 @@ class MCU:
|
||||||
self._emergency_stop_cmd = None
|
self._emergency_stop_cmd = None
|
||||||
self._is_shutdown = self._is_timeout = False
|
self._is_shutdown = self._is_timeout = False
|
||||||
self._shutdown_msg = ""
|
self._shutdown_msg = ""
|
||||||
printer.set_rollover_info(self._name, None)
|
|
||||||
# Config building
|
# Config building
|
||||||
pins.get_printer_pins(printer).register_chip(self._name, self)
|
pins.get_printer_pins(printer).register_chip(self._name, self)
|
||||||
self._oid_count = 0
|
self._oid_count = 0
|
||||||
|
@ -559,7 +558,6 @@ class MCU:
|
||||||
self._check_restart("CRC mismatch")
|
self._check_restart("CRC mismatch")
|
||||||
raise error("MCU '%s' CRC does not match config" % (self._name,))
|
raise error("MCU '%s' CRC does not match config" % (self._name,))
|
||||||
move_count = config_params['move_count']
|
move_count = config_params['move_count']
|
||||||
logging.info("Configured MCU '%s' (%d moves)", self._name, move_count)
|
|
||||||
msgparser = self._serial.msgparser
|
msgparser = self._serial.msgparser
|
||||||
info = [
|
info = [
|
||||||
"Configured MCU '%s' (%d moves)" % (self._name, move_count),
|
"Configured MCU '%s' (%d moves)" % (self._name, move_count),
|
||||||
|
|
|
@ -40,11 +40,12 @@ class QueueListener(logging.handlers.TimedRotatingFileHandler):
|
||||||
self.bg_thread.join()
|
self.bg_thread.join()
|
||||||
def set_rollover_info(self, name, info):
|
def set_rollover_info(self, name, info):
|
||||||
self.rollover_info[name] = info
|
self.rollover_info[name] = info
|
||||||
|
def clear_rollover_info(self):
|
||||||
|
self.rollover_info.clear()
|
||||||
def doRollover(self):
|
def doRollover(self):
|
||||||
logging.handlers.TimedRotatingFileHandler.doRollover(self)
|
logging.handlers.TimedRotatingFileHandler.doRollover(self)
|
||||||
lines = [self.rollover_info[name]
|
lines = [self.rollover_info[name]
|
||||||
for name in sorted(self.rollover_info)
|
for name in sorted(self.rollover_info)]
|
||||||
if self.rollover_info[name]]
|
|
||||||
lines.append(
|
lines.append(
|
||||||
"=============== Log rollover at %s ===============" % (
|
"=============== Log rollover at %s ===============" % (
|
||||||
time.asctime(),))
|
time.asctime(),))
|
||||||
|
|
|
@ -84,11 +84,6 @@ class SerialReader:
|
||||||
msgparser.process_identify(identify_data)
|
msgparser.process_identify(identify_data)
|
||||||
self.msgparser = msgparser
|
self.msgparser = msgparser
|
||||||
self.register_callback(self.handle_unknown, '#unknown')
|
self.register_callback(self.handle_unknown, '#unknown')
|
||||||
logging.info("Loaded %d commands (%s / %s)",
|
|
||||||
len(msgparser.messages_by_id),
|
|
||||||
msgparser.version, msgparser.build_versions)
|
|
||||||
logging.info("MCU config: %s", " ".join(
|
|
||||||
["%s=%s" % (k, v) for k, v in msgparser.config.items()]))
|
|
||||||
# Setup baud adjust
|
# Setup baud adjust
|
||||||
mcu_baud = msgparser.get_constant_float('SERIAL_BAUD', None)
|
mcu_baud = msgparser.get_constant_float('SERIAL_BAUD', None)
|
||||||
if mcu_baud is not None:
|
if mcu_baud is not None:
|
||||||
|
|
Loading…
Reference in New Issue