The Assimilation Project  based on Assimilation version 1.1.7.1474836767
logwatcher.LogWatcher Class Reference
Inheritance diagram for logwatcher.LogWatcher:
Collaboration diagram for logwatcher.LogWatcher:

Public Member Functions

def __init__ (self, log, regexes, timeout=10, debug=None, returnonlymatch=False)
 
def setregexes (self, regexes)
 
def setwatch (self, frombeginning=False)
 
def ReturnOnlyMatch (self, onlymatch=True)
 
def debugmsg (self, msg, level=1)
 
def look (self, timeout=None)
 
def lookforall (self, timeout=None, logloadavg=True)
 

Data Fields

 patterns
 
 regexes
 
 filename
 
 debug
 
 returnonlymatch
 
 whichmatched
 
 unmatched
 
 st_ino
 
 st_dev
 
 logfile
 
 size
 
 Timeout
 

Detailed Description

This class watches logs for messages that fit certain regular
   expressions.  Watching logs for events isn't the ideal way
   to do business, but it's better than nothing :-)

   On the other hand, this class is really pretty cool ;-)

   The way you use this class is as follows:
      Construct a LogWatcher object
      Call setwatch() when you want to start watching the log
      Call look() to scan the log looking for the patterns
        or call lookforall() to locate them all

Definition at line 42 of file logwatcher.py.

Constructor & Destructor Documentation

def logwatcher.LogWatcher.__init__ (   self,
  log,
  regexes,
  timeout = 10,
  debug = None,
  returnonlymatch = False 
)
This is the constructor for the LogWatcher class.  It takes a
log name to watch, and a list of regular expressions to watch for."

@FIXME: should store the compiled regexes - no point in waiting around
until later.

Definition at line 57 of file logwatcher.py.

Member Function Documentation

def logwatcher.LogWatcher.debugmsg (   self,
  msg,
  level = 1 
)
def logwatcher.LogWatcher.look (   self,
  timeout = None 
)
Examine the log looking for the given patterns.
It starts looking from the place marked by setwatch().
This function looks in the file in the fashion of tail -f.
It properly recovers from log file truncation, and it should
recover from removing and recreating the log as well.

We return the first line which matches any of our patterns.

Definition at line 118 of file logwatcher.py.

References logwatcher.LogWatcher._match_against_regexes(), logwatcher.LogWatcher.debugmsg(), logwatcher.LogWatcher.filename, cma.cmadb.Neo4jCreds.filename, logwatcher.LogWatcher.regexes, logwatcher.LogWatcher.returnonlymatch, logwatcher.LogWatcher.setwatch(), logwatcher.LogWatcher.size, logwatcher.LogWatcher.st_dev, logwatcher.LogWatcher.st_ino, logwatcher.LogWatcher.Timeout, logwatcher.LogWatcher.unmatched, and logwatcher.LogWatcher.whichmatched.

Referenced by logwatcher.LogWatcher.lookforall().

Here is the call graph for this function:

Here is the caller graph for this function:

def logwatcher.LogWatcher.lookforall (   self,
  timeout = None,
  logloadavg = True 
)
Examine the log looking for ALL of the given patterns.
It starts looking from the place marked by setwatch().

We return when the timeout is reached, or when we have found
ALL of the regexes that were part of the watch
Note that the order of the REGEXes is not relevant.  They can
be occur in the logs in any order.  Hope that's what you wanted ;-)

Definition at line 192 of file logwatcher.py.

References logwatcher.LogWatcher.debugmsg(), logwatcher.LogWatcher.look(), logwatcher.LogWatcher.regexes, logwatcher.LogWatcher.Timeout, logwatcher.LogWatcher.unmatched, and logwatcher.LogWatcher.whichmatched.

Here is the call graph for this function:

def logwatcher.LogWatcher.ReturnOnlyMatch (   self,
  onlymatch = True 
)
Set the ReturnOnlyMatch flag

Definition at line 105 of file logwatcher.py.

References logwatcher.LogWatcher.returnonlymatch.

def logwatcher.LogWatcher.setregexes (   self,
  regexes 
)
Set or modify the collection of regular expressions that we're looking for

Definition at line 82 of file logwatcher.py.

References logwatcher.LogWatcher.patterns, and logwatcher.LogWatcher.regexes.

def logwatcher.LogWatcher.setwatch (   self,
  frombeginning = False 
)
Mark the place to start watching the log from.

Definition at line 91 of file logwatcher.py.

References logwatcher.LogWatcher.filename, cma.cmadb.Neo4jCreds.filename, logwatcher.LogWatcher.logfile, logwatcher.LogWatcher.size, logwatcher.LogWatcher.st_dev, and logwatcher.LogWatcher.st_ino.

Referenced by logwatcher.LogWatcher.look().

Here is the caller graph for this function:

Field Documentation

logwatcher.LogWatcher.filename

Definition at line 68 of file logwatcher.py.

Referenced by logwatcher.LogWatcher.look(), and logwatcher.LogWatcher.setwatch().

logwatcher.LogWatcher.logfile

Definition at line 75 of file logwatcher.py.

Referenced by logwatcher.LogWatcher.setwatch().

logwatcher.LogWatcher.patterns

Definition at line 65 of file logwatcher.py.

Referenced by logwatcher.LogWatcher.setregexes().

logwatcher.LogWatcher.regexes
logwatcher.LogWatcher.returnonlymatch
logwatcher.LogWatcher.size

Definition at line 76 of file logwatcher.py.

Referenced by logwatcher.LogWatcher.look(), and logwatcher.LogWatcher.setwatch().

logwatcher.LogWatcher.st_dev

Definition at line 74 of file logwatcher.py.

Referenced by logwatcher.LogWatcher.look(), and logwatcher.LogWatcher.setwatch().

logwatcher.LogWatcher.st_ino

Definition at line 73 of file logwatcher.py.

Referenced by logwatcher.LogWatcher.look(), and logwatcher.LogWatcher.setwatch().

logwatcher.LogWatcher.Timeout

Definition at line 78 of file logwatcher.py.

Referenced by logwatcher.LogWatcher.look(), and logwatcher.LogWatcher.lookforall().

logwatcher.LogWatcher.unmatched

Definition at line 72 of file logwatcher.py.

Referenced by logwatcher.LogWatcher.look(), and logwatcher.LogWatcher.lookforall().

logwatcher.LogWatcher.whichmatched

Definition at line 71 of file logwatcher.py.

Referenced by logwatcher.LogWatcher.look(), and logwatcher.LogWatcher.lookforall().


The documentation for this class was generated from the following file: