equal
deleted
inserted
replaced
30 Get a set of dates, telling which days in the given month (as a datetime) have logs available |
30 Get a set of dates, telling which days in the given month (as a datetime) have logs available |
31 """ |
31 """ |
32 |
32 |
33 abstract |
33 abstract |
34 |
34 |
35 def get_search (self, query) : |
|
36 """ |
|
37 Search the logs for the given query |
|
38 """ |
|
39 |
|
40 abstract |
|
41 |
|
42 class LogFile (object) : |
35 class LogFile (object) : |
43 """ |
36 """ |
44 A file containing LogEvents |
37 A file containing LogEvents |
45 |
38 |
46 XXX: modify to implement LogSource? |
39 XXX: modify to implement LogSource? |
70 |
63 |
71 # seek to beginning |
64 # seek to beginning |
72 self.file.seek(0) |
65 self.file.seek(0) |
73 |
66 |
74 # iterate over lines, decoding them as well |
67 # iterate over lines, decoding them as well |
75 return (line.decode(self.charset) for line in self.file) |
68 return (line.decode(self.charset).rstrip(self.sep) for line in self.file) |
76 |
69 |
77 def read_full (self) : |
70 def read_full (self) : |
78 """ |
71 """ |
79 Reads all LogLines. The LogLines will have a valid offset |
72 Reads all LogLines. The LogLines will have a valid offset |
80 """ |
73 """ |
411 days.add(date) |
404 days.add(date) |
412 |
405 |
413 # return set |
406 # return set |
414 return days |
407 return days |
415 |
408 |
416 def get_search (self, query) : |
|
417 """ |
|
418 Just inspect the latest logfile |
|
419 """ |
|
420 |
|
421 # one logfile |
|
422 logfile = self._iter_logfile_reverse().next() |
|
423 |
|
424 # inspect each line |
|
425 for line in logfile.read_full() : |
|
426 # XXX: use proper LogQuery stuff |
|
427 if query in line.data : |
|
428 yield line |
|
429 |
|
430 |
|