equal
deleted
inserted
replaced
18 """ |
18 """ |
19 |
19 |
20 self.tz = tz |
20 self.tz = tz |
21 self.timestamp_fmt = timestamp_fmt |
21 self.timestamp_fmt = timestamp_fmt |
22 |
22 |
23 def parse_lines (self, lines, date=None) : |
23 def parse_lines (self, lines, date=None, starting_offset=None) : |
24 """ |
24 """ |
25 Parse the given (iterable) lines of unicode text into a LogEvent, no trailing newline. |
25 Parse the given (iterable) lines of unicode text into a LogEvent, no trailing newline. |
|
26 |
|
27 Offset is the starting offset, and may be None to not use it. |
26 |
28 |
27 Giving date lets the parser build full timestamps, otherwise, unless line timestamps have full date |
29 Giving date lets the parser build full timestamps, otherwise, unless line timestamps have full date |
28 information, event timestamps will have a date component of 1900/1/1. |
30 information, event timestamps will have a date component of 1900/1/1. |
29 """ |
31 """ |
30 |
32 |
34 class IrssiParser (LogParser) : |
36 class IrssiParser (LogParser) : |
35 """ |
37 """ |
36 A parser for irssi logfiles |
38 A parser for irssi logfiles |
37 """ |
39 """ |
38 |
40 |
39 def parse_lines (self, lines, date=None) : |
41 def parse_lines (self, lines, date=None, starting_offset=None) : |
40 """ |
42 """ |
41 Parse the given lines, yielding LogEvents. |
43 Parse the given lines, yielding LogEvents. |
42 """ |
44 """ |
43 |
45 |
44 for line in lines : |
46 for offset, line in enumerate(lines) : |
45 # status lines |
47 # status lines |
46 if line.startswith('---') : |
48 if line.startswith('---') : |
47 # XXX: handle these |
49 # XXX: handle these |
48 continue |
50 continue |
49 |
51 |
60 dt = dt.replace(year=date.year, month=date.month, day=date.day) |
62 dt = dt.replace(year=date.year, month=date.month, day=date.day) |
61 |
63 |
62 # now localize with timezone |
64 # now localize with timezone |
63 dtz = self.tz.localize(dt) |
65 dtz = self.tz.localize(dt) |
64 |
66 |
|
67 # offset? |
|
68 if offset : |
|
69 offset = starting_offset + offset |
|
70 |
|
71 else : |
|
72 offset = None |
|
73 |
65 # yield raw events |
74 # yield raw events |
66 yield log_line.LogLine(LogTypes.RAW, dtz, None, data) |
75 yield log_line.LogLine(offset, LogTypes.RAW, dtz, None, data) |
67 |
76 |