Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.pipe.seek(location)
line = self.pipe.read(mass) + halfline
data = line.split('\n')
if location != 0:
halfline = data.pop(0)
loc = location + mass
data.reverse()
for line in data:
if line.strip() == '':
continue
yield (loc, line)
loc -= len(line)
class CronLog(LogReader):
"""Use the LogReader to make a Cron specific log reader"""
def __init__(self, filename='/var/log/syslog', user=None):
LogReader.__init__(self, filename)
self.user = user
def for_program(self, command):
"""Return log entries for this specific command name"""
return ProgramLog(self, command)
def __iter__(self):
for line in super(CronLog, self).__iter__():
match = re.match(MATCHER, unicode(line))
datum = match and match.groupdict()
if datum and (not self.user or datum['user'] == self.user):
datum['date'] = dateparse.parse(datum['date'])
yield datum
def __init__(self, filename='/var/log/syslog', user=None):
LogReader.__init__(self, filename)
self.user = user