Skip to content

Commit

Permalink
Merge pull request #11 from herrfrei/master
Browse files Browse the repository at this point in the history
Added log file support with argument -o / --output
  • Loading branch information
blavka authored May 29, 2020
2 parents 7ed2452 + 267ab05 commit f665497
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mqtt2influxdb/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ def main():
argp = argparse.ArgumentParser(description='MQTT to InfluxDB')
argp.add_argument('-c', '--config', help='path to configuration file (YAML format)', required=True)
argp.add_argument('-D', '--debug', help='print debug messages', action='store_true')
argp.add_argument('-o', '--output', help='output log messages to file')
argp.add_argument('-t', '--test', help='test parse config', action='store_true')
argp.add_argument('-d', '--daemon', help='on connection error instead of exiting just wait for some time and try again', action='store_true')
argp.add_argument('-v', '--version', action='version', version='%(prog)s ' + __version__)
args = argp.parse_args()

logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO, format=LOG_FORMAT)
log_file = None
if args.output:
log_file = args.output

logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO, format=LOG_FORMAT, filename=log_file)

try:
config = load_config(args.config)
Expand Down

0 comments on commit f665497

Please sign in to comment.