argparser.add_argument('-l', '--logs', help='services to analyse', required=False)
argparser.add_argument('-nl', '--ignore-logs', help='skip these services (takes precedence over -l)', required=False)
argparser.add_argument('-es', '--embed-styles', help='make CSS rules inline rather than linking the file', required=False, default=False, action='store_true')
- argparser.add_argument('-nh', '--plain', help='write/send plain text rather than HTML', required = False, default=False, action='store_true')
+ argparser.add_argument('-nh', '--plain', help='write/send plain text rather than HTML', required=False, default=False, action='store_true')
+ argparser.add_argument('-q', '--quiet', help='no output to stdout', required=False, default=False, action='store_true')
# Load config
if argparser.parse_args().config:
logger = logging.getLogger(__name__)
loghandler = logging.handlers.SysLogHandler(address = '/dev/log')
loghandler.setFormatter(logging.Formatter(fmt='logparse.py[' + str(os.getpid()) + ']: %(message)s'))
- loghandler.setLevel(logging.WARNING) # don't spam syslog with debug messages
- if argparser.parse_args().verbose or (config.prefs['verbose'] == 'y' or config.prefs['verbose'] == 'yes'):
+ loghandler.setLevel(logging.INFO) # don't spam syslog with debug messages
+ if argparser.parse_args().quiet or config.prefs['quiet']:
+ logging.basicConfig(level=logging.CRITICAL)
+ elif argparser.parse_args().verbose or config.prefs['verbose']:
logging.basicConfig(level=logging.DEBUG)
logger.debug("Verbose mode turned on")
else:
output.embed_css(prefs['css'])
if (not os.path.isfile(dest_path)) and not (argparser.parse_args().overwrite or config['overwrite']):
output.write(dest_path)
+ elif logging.root.level == logging.CRITICAL:
+ pass
else:
logger.warning("Destination file already exists")
if input("Would you like to overwrite {0}? (y/n) [n] ".format(dest_path)) == 'y':
section.append_data(temp_data)
finally:
- logger.info("Finished reading onboard temperatures")
+ logger.debug("Finished reading onboard temperatures")
sensors.cleanup()
logger.debug("Sum of temperatures: {}; Number of drives: {}; => Avg disk temp is {}".format(str(sumtemp), str(len(drives)), hddavg))
hddtemp_data.subtitle += " (avg {0}{1}{2})".format(str(hddavg), DEG, CEL)
- logger.info("Finished processing drive temperatures")
-
+ logger.debug("Finished processing drive temperatures")
logger.info("Finished temp section")
+
return section