Fix: libcompat is now part of libcommon
[lttng-tools.git] / doc / python-howto.txt
CommitLineData
36907cb5
DS
1PYTHON BINDINGS
2----------------
3
4This is a brief howto for using the lttng-tools Python module.
5
6By default, the Python bindings are not installed.
7If you wish the Python bindings, you can configure with the
8--enable-python-bindings option during the installation procedure:
9
10 $ ./configure --enable-python-bindings
11
12The Python module is automatically generated using SWIG, therefore the
13swig2.0 package on Debian/Ubuntu is requied.
14
15Once installed, the Python module can be used by importing it in Python.
16In the Python interpreter:
17
18 >>> import lttng
19
20Example:
21----------------
22
23Quick example using Python to trace with LTTng.
24
251) Run python
26
27 $ python
28
292) Import the lttng module
30
31 >>> import lttng
32
333) Create a session
34
35 >>> lttng.create("session-name", "path/to/trace")
36
374) Create a handle for the tracing session and domain
38
39 >>> domain = lttng.Domain()
40 >>> domain.type = lttng.DOMAIN_KERNEL *
41 >>> handle = lttng.Handle("session-name", domain)
42
43* This line is somewhat useless since domain.type is set to 0
44 by default, the corresponding value of lttng.DOMAIN_KERNEL
45
465) Enable all Kernel events
47
48 >>> event = lttng.Event()
49 >>> event.type = lttng.EVENT_TRACEPOINT *
50 >>> event.loglevel_type = lttng.EVENT_LOGLEVEL_ALL *
51 >>> lttng.enable_event(handle, event, None)
52
53* These two lines are somewhat useless since event.type
54 and event.loglevel_type are by default set to 0, the
55 corresponding value of lttng.EVENT_TRACEPOINT and
56 lttng.EVENT_LOGLEVEL_ALL
57
585) Start tracing
59
60 >>> lttng.start("session-name")
61
626) Stop tracing
63
64 >>> lttng.stop("session-name")
65
667) Destroy the tracing session
67
68 >>> lttng.destroy("session-name")
69
70For an example script with more details, see extras/bindings/swig/python/tests/example.py
This page took 0.058343 seconds and 5 git commands to generate.