tensor.logs

tensor.logs.follower

class tensor.logs.follower.LogFollower(logfile, parser=None, tmp_path='/var/lib/tensor/', history=False)[source]

Bases: object

Provides a class for following log files between runs

Parameters:
  • logfile (str) – Full path to logfile
  • parser (str) – Optional parser method for log lines
get(max_lines=None)[source]

Returns a big list of all log lines since the last run

get_fn(fn, max_lines=None)[source]

Passes each parsed log line to fn This is a better idea than storing a giant log file in memory

tensor.logs.parsers

class tensor.logs.parsers.ApacheLogParser(format)[source]

Parses Apache log format

Adapted from http://code.google.com/p/apachelog

Parameters:format (str) – Apache log format definition eg r’%h %l %u %t “%r” %>s %b “%{Referer}i” “%{User-Agent}i”’ or one of ‘common’, ‘vhcommon’ or ‘combined’
names()[source]

Returns the field names the parser extracted from the input format (a list)

parse(line)[source]

Parses a single line from the log file and returns a dictionary of it’s contents.

Raises and exception if it couldn’t parse the line

pattern()[source]

Returns the compound regular expression the parser extracted from the input format (a string)