Esempio n. 1
0
    def test_logfollow(self):
        try:
            os.unlink('test.log.lf')
            os.unlink('test.log')
        except:
            pass

        log = open('test.log', 'wt')
        log.write('foo\nbar\n')
        log.flush()

        f = follower.LogFollower('test.log', tmp_path=".", history=True)

        r = f.get()

        log.write('test')
        log.flush()

        r2 = f.get()

        log.write('ing\n')
        log.flush()

        r3 = f.get()

        self.assertEqual(r[0], 'foo')
        self.assertEqual(r[1], 'bar')

        self.assertEqual(r2, [])
        self.assertEqual(r3[0], 'testing')

        log.close()

        # Move inode
        os.rename('test.log', 'testold.log')

        log = open('test.log', 'wt')
        log.write('foo2\nbar2\n')
        log.close()

        r = f.get()

        self.assertEqual(r[0], 'foo2')
        self.assertEqual(r[1], 'bar2')

        # Go backwards
        log = open('test.log', 'wt')
        log.write('foo3\n')
        log.close()

        r = f.get()

        self.assertEqual(r[0], 'foo3')

        os.unlink('test.log')
        os.unlink('testold.log')
Esempio n. 2
0
    def __init__(self, *a):
        Source.__init__(self, *a)

        self.parser = parsers.ApacheLogParser(
            self.config.get('log_format', 'combined'))

        self.log = follower.LogFollower(self.config['file'],
                                        parser=self._parser_proxy,
                                        history=False)

        self.max_lines = int(self.config.get('max_lines', 2000))
Esempio n. 3
0
    def __init__(self, *a):
        Source.__init__(self, *a)

        parser = parsers.ApacheLogParser(
            self.config.get('log_format', 'combined'))

        history = self.config.get('history', False)

        self.log = follower.LogFollower(self.config['file'],
                                        parser=parser.parse,
                                        history=history)

        self.max_lines = int(self.config.get('max_lines', 2000))
        self.bucket_res = int(self.config.get('resolution', 10))

        self.bucket = 0