--- a/log_source.py Tue Feb 10 01:05:35 2009 +0200
+++ b/log_source.py Tue Feb 10 01:24:59 2009 +0200
@@ -42,6 +42,15 @@
else :
skip = None
+ # go through the logs a page at a time
+ this_page = 1
+
+ # last line's timestamp
+ last_ts = None
+
+ # found it yet?
+ found = False
+
# count the full number of lines
line_count = 0
@@ -57,11 +66,31 @@
if skip :
skip -= 1
continue
-
- # already full?
- if len(lines) > count :
- continue
-
+
+ # is this page all that we want/need?
+ if page or found :
+ # already full?
+ if len(lines) >= count :
+ continue
+
+ # specfic timestamp
+ else :
+ # didn't find it in this page?
+ if len(lines) >= count :
+ # reset to next page
+ lines = []
+ this_page += 1
+
+ # is dt between these two timestamps?
+ if (not last_ts or last_ts <= dt) and (dt <= line.timestamp) :
+ # found!
+ found = True
+ page = this_page
+
+ else :
+ # keep looking
+ last_ts = line.timestamp
+
# store line
lines.append(line)