From: Philippe Proulx Date: Sat, 5 Sep 2015 17:47:13 +0000 (-0400) Subject: doc: add Python example X-Git-Tag: v2.7.0~7 X-Git-Url: http://git.lttng.org/?p=lttng-ust.git;a=commitdiff_plain;h=e1222efe51a26176dd32e0053dfc58702ce9cbce doc: add Python example Signed-off-by: Philippe Proulx Signed-off-by: Mathieu Desnoyers --- diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am index 9404054d..f3ca158c 100644 --- a/doc/examples/Makefile.am +++ b/doc/examples/Makefile.am @@ -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 index 00000000..338df774 --- /dev/null +++ b/doc/examples/python/hello.py @@ -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()