From 386e879869ec7420093c3ac477bd12ec00c6b550 Mon Sep 17 00:00:00 2001 From: Thuban <thuban@yeuxdelibad.net> Date: Sun, 03 Sep 2017 10:14:07 +0000 Subject: [PATCH] Ajout de license --- vilain.py | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/vilain.py b/vilain.py index 6294620..d36c59f 100755 --- a/vilain.py +++ b/vilain.py @@ -24,6 +24,7 @@ import configparser import re import logging +import logging.handlers import subprocess import asyncio import time @@ -38,10 +39,13 @@ sys.exit(1) # Configure logging +log_handler = logging.handlers.WatchedFileHandler(LOGFILE) +formatter = logging.Formatter( + '%(asctime)s %(module)s:%(funcName)s:%(message)s', + '%b %d %H:%M:%S') +log_handler.setFormatter(formatter) logger = logging.getLogger(__name__) -logging.basicConfig(filename=LOGFILE, - format='%(asctime)s %(module)s:%(funcName)s:%(message)s', - datefmt='%H:%M:%S') +logger.addHandler(log_handler) logger.setLevel(logging.INFO) # functions @@ -164,7 +168,7 @@ record time when this IP has been seen in ip_seen_at = { ip:{'time':<time>,'count':<counter} } and ban with pf """ - logger.info('ban_ips sarted') + logger.info('ban_ips started') while True: ip_item = await self.bad_ip_queue.get() logger.debug('ban_ips awake') @@ -185,7 +189,7 @@ """ check old ip in ip_seen_at : remove older than watch_while """ - logger.info('clean_ips sarted with sleeptime={}'.format(self.sleeptime)) + logger.info('clean_ips started with sleeptime={}'.format(self.sleeptime)) while True: await asyncio.sleep(self.watch_while) to_remove = [] -- Gitblit v1.9.3