mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-08 16:39:17 +00:00
debug log improvements
This commit is contained in:
@@ -184,9 +184,8 @@ class Options(AttrMonitor):
|
||||
self.conf = Cfg(self.confpath, self.profile, debug=self.debug,
|
||||
dry=self.dry)
|
||||
# transform the config settings to self attribute
|
||||
self._debug_dict('effective settings', self.conf.get_settings())
|
||||
for k, v in self.conf.get_settings().items():
|
||||
if self.debug:
|
||||
self.log.dbg('new setting: {}={}'.format(k, v))
|
||||
setattr(self, k, v)
|
||||
|
||||
def _apply_args(self):
|
||||
@@ -267,15 +266,41 @@ class Options(AttrMonitor):
|
||||
"""debug display all of this class attributes"""
|
||||
if not self.debug:
|
||||
return
|
||||
self.log.dbg('CLI options:')
|
||||
self.log.dbg('effective options:')
|
||||
for att in dir(self):
|
||||
if att.startswith('_'):
|
||||
continue
|
||||
val = getattr(self, att)
|
||||
if callable(val):
|
||||
continue
|
||||
self.log.dbg('- {}: {}'.format(att, val))
|
||||
if type(val) is list:
|
||||
self._debug_list('-> {}'.format(att), val)
|
||||
elif type(val) is dict:
|
||||
self._debug_dict('-> {}'.format(att), val)
|
||||
else:
|
||||
self.log.dbg('-> {}: {}'.format(att, val))
|
||||
|
||||
def _attr_set(self, attr):
|
||||
"""error when some inexistent attr is set"""
|
||||
raise Exception('bad option: {}'.format(attr))
|
||||
|
||||
def _debug_list(self, title, elems):
|
||||
"""pretty print list"""
|
||||
if not self.debug:
|
||||
return
|
||||
self.log.dbg('{}:'.format(title))
|
||||
for e in elems:
|
||||
self.log.dbg('\t- {}'.format(e))
|
||||
|
||||
def _debug_dict(self, title, elems):
|
||||
"""pretty print dict"""
|
||||
if not self.debug:
|
||||
return
|
||||
self.log.dbg('{}:'.format(title))
|
||||
for k, v in elems.items():
|
||||
if type(v) is list:
|
||||
self.log.dbg('\t- \"{}\":'.format(k))
|
||||
for i in v:
|
||||
self.log.dbg('\t\t- {}'.format(i))
|
||||
else:
|
||||
self.log.dbg('\t- \"{}\": {}'.format(k, v))
|
||||
|
||||
Reference in New Issue
Block a user