From: <los...@us...> - 2008-05-19 21:08:43
|
Revision: 697 http://fail2ban.svn.sourceforge.net/fail2ban/?rev=697&view=rev Author: lostcontrol Date: 2008-05-19 14:08:36 -0700 (Mon, 19 May 2008) Log Message: ----------- - Added and changed some logging level and messages. Modified Paths: -------------- trunk/server/filter.py trunk/server/filtergamin.py trunk/server/filterpoll.py trunk/server/jail.py trunk/server/server.py Modified: trunk/server/filter.py =================================================================== --- trunk/server/filter.py 2008-05-19 21:05:32 UTC (rev 696) +++ trunk/server/filter.py 2008-05-19 21:08:36 UTC (rev 697) @@ -64,7 +64,7 @@ self.__findTime = 6000 ## The ignore IP list. self.__ignoreIpList = [] - logSys.info("Created Filter") + logSys.debug("Created Filter") ## @@ -411,7 +411,7 @@ class FileContainer: - def __init__(self, filename, tail = False): + def __init__(self, filename, tail = True): self.__filename = filename self.__tail = tail self.__handler = None Modified: trunk/server/filtergamin.py =================================================================== --- trunk/server/filtergamin.py 2008-05-19 21:05:32 UTC (rev 696) +++ trunk/server/filtergamin.py 2008-05-19 21:08:36 UTC (rev 697) @@ -53,7 +53,7 @@ self.__modified = False # Gamin monitor self.monitor = gamin.WatchMonitor() - logSys.info("Created FilterGamin") + logSys.debug("Created FilterGamin") def callback(self, path, event): @@ -69,7 +69,7 @@ # # @param path log file path - def addLogPath(self, path, tail = False): + def addLogPath(self, path, tail = True): if self.containsLogPath(path): logSys.error(path + " already exists") else: Modified: trunk/server/filterpoll.py =================================================================== --- trunk/server/filterpoll.py 2008-05-19 21:05:32 UTC (rev 696) +++ trunk/server/filterpoll.py 2008-05-19 21:08:36 UTC (rev 697) @@ -54,14 +54,14 @@ ## The time of the last modification of the file. self.__lastModTime = dict() self.__file404Cnt = dict() - logSys.info("Created FilterPoll") + logSys.debug("Created FilterPoll") ## # Add a log file path # # @param path log file path - def addLogPath(self, path, tail = False): + def addLogPath(self, path, tail = True): if self.containsLogPath(path): logSys.error(path + " already exists") else: Modified: trunk/server/jail.py =================================================================== --- trunk/server/jail.py 2008-05-19 21:05:32 UTC (rev 696) +++ trunk/server/jail.py 2008-05-19 21:08:36 UTC (rev 697) @@ -37,6 +37,7 @@ self.__name = name self.__queue = Queue.Queue() self.__filter = None + logSys.info("Creating new jail '%s'" % self.__name) if backend == "polling": self.__initPoller() else: @@ -47,14 +48,14 @@ self.__action = Actions(self) def __initPoller(self): - logSys.info("Using poller") + logSys.info("Jail '%s' uses poller" % self.__name) from filterpoll import FilterPoll self.__filter = FilterPoll(self) def __initGamin(self): # Try to import gamin import gamin - logSys.info("Using Gamin") + logSys.info("Jail '%s' uses Gamin" % self.__name) from filtergamin import FilterGamin self.__filter = FilterGamin(self) @@ -82,12 +83,14 @@ def start(self): self.__filter.start() self.__action.start() + logSys.info("Jail '%s' started" % self.__name) def stop(self): self.__filter.stop() self.__action.stop() self.__filter.join() self.__action.join() + logSys.info("Jail '%s' stopped" % self.__name) def isAlive(self): isAlive0 = self.__filter.isAlive() Modified: trunk/server/server.py =================================================================== --- trunk/server/server.py 2008-05-19 21:05:32 UTC (rev 696) +++ trunk/server/server.py 2008-05-19 21:08:36 UTC (rev 697) @@ -46,11 +46,11 @@ self.__daemon = daemon self.__transm = Transmitter(self) self.__asyncServer = AsyncServer(self.__transm) - self.__logLevel = 3 - self.__logTarget = "STDOUT" + self.__logLevel = None + self.__logTarget = None # Set logging level - self.setLogLevel(self.__logLevel) - self.setLogTarget(self.__logTarget) + self.setLogLevel(3) + self.setLogTarget("STDOUT") def __sigTERMhandler(self, signum, frame): logSys.debug("Caught signal %d. Exiting" % signum) @@ -66,6 +66,7 @@ # First set the mask to only allow access to owner os.umask(0077) if self.__daemon: + logSys.info("Starting in daemon mode") ret = self.__createDaemon() if ret: logSys.info("Daemon started") @@ -264,7 +265,7 @@ length = len(jailList) if not length == 0: jailList = jailList[:length-2] - ret = [("Number of jail", self.__jails.size()), + ret = [("Number of jail", self.__jails.size()), ("Jail list", jailList)] return ret finally: @@ -331,7 +332,7 @@ # Syslog daemons already add date to the message. formatter = logging.Formatter("%(name)-16s: %(levelname)-6s %(message)s") facility = logging.handlers.SysLogHandler.LOG_DAEMON - hdlr = logging.handlers.SysLogHandler("/dev/log", + hdlr = logging.handlers.SysLogHandler("/dev/log", facility = facility) elif target == "STDOUT": hdlr = logging.StreamHandler(sys.stdout) @@ -346,7 +347,6 @@ logSys.error("Unable to log to " + target) logSys.info("Logging to previous target " + self.__logTarget) return False - self.__logTarget = target # Removes previous handlers for handler in logging.getLogger("fail2ban").handlers: # Closes the handler. @@ -355,6 +355,12 @@ # tell the handler to use this format hdlr.setFormatter(formatter) logging.getLogger("fail2ban").addHandler(hdlr) + # Does not display this message at startup. + if not self.__logTarget == None: + logSys.info("Changed logging target to %s for Fail2ban v%s" % + (target, version.version)) + # Sets the logging target. + self.__logTarget = target return True finally: self.__loggingLock.release() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |