X-Git-Url: http://git.treefish.org/~alex/logalert.git/blobdiff_plain/066228e2a7b4a1ae397231965d17c25bef2cd461..082f53238d44c1b52dc6a8110ec7dc4c56aa41df:/src/logalert.py diff --git a/src/logalert.py b/src/logalert.py index e2f02cc..c8eed19 100755 --- a/src/logalert.py +++ b/src/logalert.py @@ -9,10 +9,6 @@ import misc MAX_LINES = 10 ALERT_INTERVAL = 86400 -logging.basicConfig(format='[%(asctime)s] %(levelname)s: %(message)s', - level=logging.INFO, - datefmt='%m/%d/%Y %H:%M:%S') - parser = argparse.ArgumentParser(description='Alert on excessive number of error log lines.') parser.add_argument('logfile', type=str, help='logfile to be watched') parser.add_argument('handler', type=str, @@ -21,9 +17,15 @@ parser.add_argument('-s', '--interval-size', type=int, default=600, dest='interv help='sample interval size in seconds (default: 600)') parser.add_argument('-n', '--num-intervals', type=int, default=6, dest='num_intervals', help='number of intervals to keep in history (default: 6)') +parser.add_argument('-l', '--log-level', type=str, default='INFO', dest='log_lvl', + choices=['DEBUG', 'INFO', 'WARNING'], help='select log level') args = parser.parse_args() +logging.basicConfig(format='[%(asctime)s] %(levelname)s: %(message)s', + level=logging.getLevelName(args.log_lvl), + datefmt='%m/%d/%Y %H:%M:%S') + kept_times = [] lines = [] last_slot_time = None