fixbot/logwatch/__init__.py
author Tero Marttila <terom@fixme.fi>
Fri, 05 Feb 2010 21:48:14 +0200
changeset 58 31a17b0b5159
parent 48 ba101beeb062
child 62 e4db89a5f6bc
permissions -rw-r--r--
remove concept of event_types, the event.type is now just sent as a string
"""
    A module that can monitor any number of log files, and then process each incoming line, filtering and then possibly
    reformatting them before sending out to IRC.
"""

from fixbot import api

class LogWatchModule (api.Module) :
    name = "logs"
    
    def __init__ (self, config) :
        """
            Initialize with logwatch_sources from config
        """

        super(LogWatchModule, self).__init__(config)

        self.sources = config['logwatch-sources']
    
    def handleConnect (self) :
        """
            Initialize each source
        """

        for source in self.sources :
            source.setModule(self)
    
    def error (self, msg) :
        self.sendEvent("error", msg)

def makeService (config) :
    return api.makeService(LogWatchModule, config)