doc: add Python example
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 5 Sep 2015 17:47:13 +0000 (13:47 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 9 Sep 2015 21:55:39 +0000 (17:55 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
doc/examples/Makefile.am
doc/examples/python/hello.py [new file with mode: 0644]

index 3538ee6dbe5a2171a47e187b2d606b1ce068f19f..2f376e254d28fe6045badeeb7a949e62b1009568 100644 (file)
@@ -24,6 +24,11 @@ dist_doc_examples_java_log4j_DATA = java-log4j/Makefile \
 SUBDIRS_LOG4J = java-log4j
 endif
 
+if BUILD_PYTHON_AGENT
+doc_examples_pythondir = ${docdir}/examples/python
+dist_doc_examples_python_DATA = python/hello.py
+endif
+
 dist_doc_examples_DATA = README
 
 dist_doc_examples_easy_ust_DATA = easy-ust/Makefile \
diff --git a/doc/examples/python/hello.py b/doc/examples/python/hello.py
new file mode 100644 (file)
index 0000000..338df77
--- /dev/null
@@ -0,0 +1,24 @@
+import lttngust
+import logging
+import time
+import math
+
+
+def hello():
+    logger = logging.getLogger('hello-logger')
+
+    while True:
+        logger.debug('hello, debug message: %d', 23)
+        time.sleep(0.1)
+        logger.info('hello, info message: %s', 'world')
+        time.sleep(0.1)
+        logger.warn('hello, warn message')
+        time.sleep(0.1)
+        logger.error('hello, error message: %f', math.pi)
+        time.sleep(0.1)
+        logger.critical('hello, critical message')
+        time.sleep(0.5)
+
+
+if __name__ == '__main__':
+    hello()
This page took 0.025632 seconds and 5 git commands to generate.