From e1222efe51a26176dd32e0053dfc58702ce9cbce Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Sat, 5 Sep 2015 13:47:13 -0400 Subject: [PATCH] doc: add Python example Signed-off-by: Philippe Proulx Signed-off-by: Mathieu Desnoyers --- doc/examples/Makefile.am | 5 +++++ doc/examples/python/hello.py | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 doc/examples/python/hello.py 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() -- 2.34.1