How to use the crontab.cronlog.LogReader function in crontab

To help you get started, we’ve selected a few crontab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github achaudhry / adhan / crontab / cronlog.py View on Github external
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
github achaudhry / adhan / crontab / cronlog.py View on Github external
def __init__(self, filename='/var/log/syslog', user=None):
        LogReader.__init__(self, filename)
        self.user = user