1tracing(3)                 Library Functions Manual                 tracing(3)
2
3
4

NAME

6       tracing - Tracing Runtime tracing is controlled by environment
7       variables.
8
9       Tracing is switched on by setting MQTT_C_CLIENT_TRACE. A value of ON,
10       or stdout, prints to stdout, any other value is interpreted as a file
11       name to use.
12
13       The amount of trace detail is controlled with the
14       MQTT_C_CLIENT_TRACE_LEVEL environment variable - valid values are
15       ERROR, PROTOCOL, MINIMUM, MEDIUM and MAXIMUM (from least to most
16       verbose).
17
18       The variable MQTT_C_CLIENT_TRACE_MAX_LINES limits the number of lines
19       of trace that are output to a file. Two files are used at most, when
20       they are full, the last one is overwritten with the new trace entries.
21       The default size is 1000 lines.
22
23   MQTT Packet Tracing
24       A feature that can be very useful is printing the MQTT packets that are
25       sent and received. To achieve this, use the following environment
26       variable settings:
27
28       MQTT_C_CLIENT_TRACE=ON
29       MQTT_C_CLIENT_TRACE_LEVEL=PROTOCOL
30
31
32        The output you should see looks like this:
33
34       20130528 155936.813 3 stdout-subscriber -> CONNECT cleansession: 1 (0)
35       20130528 155936.813 3 stdout-subscriber <- CONNACK rc: 0
36       20130528 155936.813 3 stdout-subscriber -> SUBSCRIBE msgid: 1 (0)
37       20130528 155936.813 3 stdout-subscriber <- SUBACK msgid: 1
38       20130528 155941.818 3 stdout-subscriber -> DISCONNECT (0)
39
40
41        where the fields are:
42
43       1.  date
44
45       2.  time
46
47       3.  socket number
48
49       4.  client id
50
51       5.  direction (-> from client to server, <- from server to client)
52
53       6.  packet details
54
55   Default Level Tracing
56       This is an extract of a default level trace of a call to connect:
57
58       19700101 010000.000 (1152206656) (0)> MQTTClient_connect:893
59       19700101 010000.000 (1152206656)  (1)> MQTTClient_connectURI:716
60       20130528 160447.479 Connecting to serverURI localhost:1883
61       20130528 160447.479 (1152206656)   (2)> MQTTProtocol_connect:98
62       20130528 160447.479 (1152206656)    (3)> MQTTProtocol_addressPort:48
63       20130528 160447.479 (1152206656)    (3)< MQTTProtocol_addressPort:73
64       20130528 160447.479 (1152206656)    (3)> Socket_new:599
65       20130528 160447.479 New socket 4 for localhost, port 1883
66       20130528 160447.479 (1152206656)     (4)> Socket_addSocket:163
67       20130528 160447.479 (1152206656)      (5)> Socket_setnonblocking:73
68       20130528 160447.479 (1152206656)      (5)< Socket_setnonblocking:78 (0)
69       20130528 160447.479 (1152206656)     (4)< Socket_addSocket:176 (0)
70       20130528 160447.479 (1152206656)     (4)> Socket_error:95
71       20130528 160447.479 (1152206656)     (4)< Socket_error:104 (115)
72       20130528 160447.479 Connect pending
73       20130528 160447.479 (1152206656)    (3)< Socket_new:683 (115)
74       20130528 160447.479 (1152206656)   (2)< MQTTProtocol_connect:131 (115)
75
76
77        where the fields are:
78
79       1.  date
80
81       2.  time
82
83       3.  thread id
84
85       4.  function nesting level
86
87       5.  function entry (>) or exit (<)
88
89       6.  function name : line of source code file
90
91       7.  return value (if there is one)
92
93   Memory Allocation Tracing
94       Setting the trace level to maximum causes memory allocations and frees
95       to be traced along with the default trace entries, with messages like
96       the following:
97
98       20130528 161819.657 Allocating 16 bytes in heap at file /home/icraggs/workspaces/mqrtc/mqttv3c/src/MQTTPacket.c line 177 ptr 0x179f930
99
100       20130528 161819.657 Freeing 16 bytes in heap at file /home/icraggs/workspaces/mqrtc/mqttv3c/src/MQTTPacket.c line 201, heap use now 896 bytes
101
102
103        When the last MQTT client object is destroyed, if the trace is being
104       recorded and all memory allocated by the client library has not been
105       freed, an error message will be written to the trace. This can help
106       with fixing memory leaks. The message will look like this:
107
108       20130528 163909.208 Some memory not freed at shutdown, possible memory leak
109       20130528 163909.208 Heap scan start, total 880 bytes
110       20130528 163909.208 Heap element size 32, line 354, file /home/icraggs/workspaces/mqrtc/mqttv3c/src/MQTTPacket.c, ptr 0x260cb00
111       20130528 163909.208   Content
112       20130528 163909.209 Heap scan end
113
114
115Paho MQTT C Client Library      Fri Jul 22 2022                     tracing(3)
Impressum