klippy: Log the contents of the config file at startup

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2016-12-24 10:17:12 -05:00
parent 451ffd567d
commit d0c61f0f76
2 changed files with 10 additions and 3 deletions

View File

@ -31,9 +31,6 @@ Host user interaction
* Automatically roll Klippy log files. The default log file should * Automatically roll Klippy log files. The default log file should
have the current date in the log file name. have the current date in the log file name.
* Report the Klippy git version in log file. Log the contents of the
config file at startup.
* Possibly collate and report the statistics messages in the log in a * Possibly collate and report the statistics messages in the log in a
more friendly way. more friendly way.

View File

@ -73,6 +73,14 @@ class ConfigWrapper:
def getsection(self, section): def getsection(self, section):
return ConfigWrapper(self.printer, section) return ConfigWrapper(self.printer, section)
class ConfigLogger():
def __init__(self, cfg):
logging.info("===== Config file =====")
cfg.write(self)
logging.info("=======================")
def write(self, data):
logging.info(data.strip())
class Printer: class Printer:
def __init__(self, conffile, input_fd, is_fileinput=False): def __init__(self, conffile, input_fd, is_fileinput=False):
self.conffile = conffile self.conffile = conffile
@ -112,6 +120,8 @@ class Printer:
if not res: if not res:
raise ConfigParser.Error("Unable to open config file %s" % ( raise ConfigParser.Error("Unable to open config file %s" % (
self.conffile,)) self.conffile,))
if self.debugoutput is None:
ConfigLogger(self.fileconfig)
self.mcu = mcu.MCU(self, ConfigWrapper(self, 'mcu')) self.mcu = mcu.MCU(self, ConfigWrapper(self, 'mcu'))
if self.fileconfig.has_section('fan'): if self.fileconfig.has_section('fan'):
self.objects['fan'] = fan.PrinterFan( self.objects['fan'] = fan.PrinterFan(