Permalink
Browse files

Log grepping script.

  • Loading branch information...
mustpax committed Aug 31, 2012
1 parent a12ef25 commit c0ec85bc7d621a88cac6cb81ee296300f5213d3d
Showing with 25 additions and 0 deletions.
  1. +25 −0 build/loggrep.py
View
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+import sys
+
+def group_lines(fd):
+ buf = []
+ for line in fd:
+ line = line.rstrip()
+ if len(line) and line[0] != '\t':
+ yield buf
+ buf = [];
+ buf.append(line)
+
+def main(pattern):
+ import re
+ pat = re.compile(pattern)
+ for line in group_lines(sys.stdin):
+ if any(map(lambda x: re.search(pat, x), line)):
+ print '\n'.join(line)
+
+if __name__ == '__main__':
+ if len(sys.argv) < 2:
+ print 'Grep through Appengine logs, reading from stdin. Usage: ./loggrep.py [regular expression]'
+ sys.exit(1)
+ main(*sys.argv[1:])

0 comments on commit c0ec85b

Please sign in to comment.