Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Documentation and example of the Python API

  • Loading branch information...
commit d347e0adc88c29470b1376b69e1b39b2ea312934 1 parent b0b5343
Julien Palard authored
Showing with 41 additions and 0 deletions.
  1. +4 −0 ChangeLog
  2. +13 −0 README
  3. +24 −0 examples/example1.py
View
4 ChangeLog
@@ -1,3 +1,7 @@
+2013-08-10 18:04:37 +0200 Julien Palard <julien@eeple.fr>
+
+ * Documentation and example of the Python API
+
2013-08-10 17:45:24 +0200 Julien Palard <julien@eeple.fr>
* Documentation and example of the C API
View
13 README
@@ -59,6 +59,19 @@ C API :
You can find an example of using the C API in examples/example1.c
+Python API :
+ logtop module exposes a logtop class containing :
+ logtop.__init__(history_size) to build a new logtop keeping
+ at most history_size lines.
+ logtop.feed(line) to feed a new line in logtop.
+ logtop.get(qte_of_elements) to get the top qte_of_elements lines.
+ logtop.qte_of_elements() to get the current total number of lines.
+ logtop.timespan() to get the duration from the oldest line to now.
+
+ timespan may be less than the runtime, as logtop drop old lines,
+ to keep, at most, history_size lines, given in the constructor of
+ the logtop class.
+
About libavl:
The libavl used here is the Ben Pfaff's one, statically build with logtop, as
Ben want it to be (see INSTALL file and here :
View
24 examples/example1.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+import pprint
+import sys
+sys.path.append('..')
+
+from logtop import logtop
+
+
+"""
+
+This example show a complete usage of the python API,
+It can be used like this :
+
+$ make python-module
+$ cat /etc/passwd | cut -d: -f7 | python example1.py
+
+"""
+
+l = logtop(10000)
+for line in sys.stdin:
+ l.feed(line)
+
+pprint.pprint(l.get(10))
Please sign in to comment.
Something went wrong with that request. Please try again.