Add color configuration to statistics command
This commit is contained in:
parent
2f7002fc67
commit
6b9f21fd08
@ -222,7 +222,7 @@ def error(data, error=None, timestamp=True):
|
|||||||
if not error is None:
|
if not error is None:
|
||||||
debug('Error: ' + str(error) + parse_error())
|
debug('Error: ' + str(error) + parse_error())
|
||||||
|
|
||||||
# fatal: when the something so bad has happened that the prorgam must stop
|
# fatal: when the something so bad has happened that the program must stop
|
||||||
def fatal(data, timestamp=True):
|
def fatal(data, timestamp=True):
|
||||||
if get_level() <= LEVEL_FATAL:
|
if get_level() <= LEVEL_FATAL:
|
||||||
log('#', data, colors.bg.red + colors.fg.green + colors.bold, timestamp=timestamp)
|
log('#', data, colors.bg.red + colors.fg.green + colors.bold, timestamp=timestamp)
|
||||||
|
@ -574,6 +574,16 @@ class Onionr:
|
|||||||
'Enabled Plugins Count' : str(len(config.get('plugins')['enabled'])) + ' / ' + str(len(os.listdir('data/plugins/')))
|
'Enabled Plugins Count' : str(len(config.get('plugins')['enabled'])) + ' / ' + str(len(os.listdir('data/plugins/')))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# color configuration
|
||||||
|
colors = {
|
||||||
|
'title' : logger.colors.bold,
|
||||||
|
'key' : logger.colors.fg.lightgreen,
|
||||||
|
'val' : logger.colors.fg.green,
|
||||||
|
'border' : logger.colors.fg.lightblue,
|
||||||
|
|
||||||
|
'reset' : logger.colors.reset
|
||||||
|
}
|
||||||
|
|
||||||
# pre-processing
|
# pre-processing
|
||||||
maxlength = 0
|
maxlength = 0
|
||||||
for key, val in messages.items():
|
for key, val in messages.items():
|
||||||
@ -581,14 +591,14 @@ class Onionr:
|
|||||||
maxlength = max(len(key), maxlength)
|
maxlength = max(len(key), maxlength)
|
||||||
|
|
||||||
# generate stats table
|
# generate stats table
|
||||||
logger.info(logger.colors.bold + 'Onionr v%s Statistics' % ONIONR_VERSION + logger.colors.reset)
|
logger.info(colors['title'] + 'Onionr v%s Statistics' % ONIONR_VERSION + colors['reset'])
|
||||||
logger.info('─' * (maxlength + 1) + '┐')
|
logger.info(colors['border'] + '─' * (maxlength + 1) + '┐' + colors['reset'])
|
||||||
for key, val in messages.items():
|
for key, val in messages.items():
|
||||||
if not (type(val) is bool and val is True):
|
if not (type(val) is bool and val is True):
|
||||||
logger.info(str(key).rjust(maxlength) + ' │ ' + str(val))
|
logger.info(colors['key'] + str(key).rjust(maxlength) + colors['reset'] + colors['border'] + ' │ ' + colors['reset'] + colors['val'] + str(val) + colors['reset'])
|
||||||
else:
|
else:
|
||||||
logger.info('─' * (maxlength + 1) + '┤')
|
logger.info(colors['border'] + '─' * (maxlength + 1) + '┤' + colors['reset'])
|
||||||
logger.info('─' * (maxlength + 1) + '┘')
|
logger.info(colors['border'] + '─' * (maxlength + 1) + '┘' + colors['reset'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error('Failed to generate statistics table.', error = e, timestamp = False)
|
logger.error('Failed to generate statistics table.', error = e, timestamp = False)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user