From: Philippe Proulx Date: Sat, 5 Sep 2015 17:47:13 +0000 (-0400) Subject: doc: add Python example X-Git-Tag: v2.8.0-rc1~78 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=372587317b19636c05ce40cc1da40e2047481b81;p=lttng-ust.git 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 3538ee6d..2f376e25 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()