2 * Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
4 * gstlog.c: tracing module that logs events
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 * @short_description: log hook event
25 * A tracing module that logs all data from all hooks.
34 #include <gst/printf/printf.h>
36 GST_DEBUG_CATEGORY_STATIC (gst_log_debug);
37 #define GST_CAT_DEFAULT gst_log_debug
38 GST_DEBUG_CATEGORY_STATIC (GST_CAT_BIN);
39 GST_DEBUG_CATEGORY_STATIC (GST_CAT_BUFFER);
40 GST_DEBUG_CATEGORY_STATIC (GST_CAT_BUFFER_LIST);
41 GST_DEBUG_CATEGORY_STATIC (GST_CAT_EVENT);
42 GST_DEBUG_CATEGORY_STATIC (GST_CAT_MESSAGE);
43 GST_DEBUG_CATEGORY_STATIC (GST_CAT_QUERY);
44 GST_DEBUG_CATEGORY_STATIC (GST_CAT_STATES);
45 GST_DEBUG_CATEGORY_STATIC (GST_CAT_PADS);
46 GST_DEBUG_CATEGORY_STATIC (GST_CAT_ELEMENT_PADS);
47 GST_DEBUG_CATEGORY_STATIC (GST_CAT_ELEMENT_FACTORY);
50 GST_DEBUG_CATEGORY_INIT (gst_log_debug, "log", 0, "log tracer"); \
51 GST_DEBUG_CATEGORY_GET (GST_CAT_BUFFER, "GST_BUFFER"); \
52 GST_DEBUG_CATEGORY_GET (GST_CAT_BUFFER_LIST, "GST_BUFFER_LIST"); \
53 GST_DEBUG_CATEGORY_GET (GST_CAT_EVENT, "GST_EVENT"); \
54 GST_DEBUG_CATEGORY_GET (GST_CAT_MESSAGE, "GST_MESSAGE"); \
55 GST_DEBUG_CATEGORY_GET (GST_CAT_STATES, "GST_STATES"); \
56 GST_DEBUG_CATEGORY_GET (GST_CAT_PADS, "GST_PADS"); \
57 GST_DEBUG_CATEGORY_GET (GST_CAT_ELEMENT_PADS, "GST_ELEMENT_PADS"); \
58 GST_DEBUG_CATEGORY_GET (GST_CAT_ELEMENT_FACTORY, "GST_ELEMENT_FACTORY"); \
59 GST_DEBUG_CATEGORY_GET (GST_CAT_QUERY, "query"); \
60 GST_DEBUG_CATEGORY_GET (GST_CAT_BIN, "bin");
61 #define gst_log_tracer_parent_class parent_class
62 G_DEFINE_TYPE_WITH_CODE (GstLogTracer, gst_log_tracer, GST_TYPE_TRACER,
66 do_log (GstDebugCategory * cat, const char *fmt, ...)
70 va_start (var_args, fmt);
71 gst_debug_log_valist (cat, GST_LEVEL_TRACE, "", "", 0, NULL, fmt, var_args);
76 do_push_buffer_pre (GstTracer * self, guint64 ts, GstPad * pad,
79 do_log (GST_CAT_BUFFER,
80 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", buffer=%" GST_PTR_FORMAT,
81 GST_TIME_ARGS (ts), pad, buffer);
85 do_push_buffer_post (GstTracer * self, guint64 ts, GstPad * pad,
88 do_log (GST_CAT_BUFFER,
89 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d",
90 GST_TIME_ARGS (ts), pad, res);
94 do_push_buffer_list_pre (GstTracer * self, guint64 ts, GstPad * pad,
97 do_log (GST_CAT_BUFFER_LIST,
98 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", list=%p",
99 GST_TIME_ARGS (ts), pad, list);
103 do_push_buffer_list_post (GstTracer * self, guint64 ts, GstPad * pad,
106 do_log (GST_CAT_BUFFER_LIST,
107 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d",
108 GST_TIME_ARGS (ts), pad, res);
112 do_pull_range_pre (GstTracer * self, guint64 ts, GstPad * pad, guint64 offset,
115 do_log (GST_CAT_BUFFER,
116 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", offset=%" G_GUINT64_FORMAT
117 ", size=%u", GST_TIME_ARGS (ts), pad, offset, size);
121 do_pull_range_post (GstTracer * self, guint64 ts, GstPad * pad,
122 GstBuffer * buffer, GstFlowReturn res)
124 do_log (GST_CAT_BUFFER,
125 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", buffer=%" GST_PTR_FORMAT
126 ", res=%d", GST_TIME_ARGS (ts), pad, buffer, res);
130 do_push_event_pre (GstTracer * self, guint64 ts, GstPad * pad, GstEvent * event)
132 do_log (GST_CAT_EVENT,
133 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", event=%" GST_PTR_FORMAT,
134 GST_TIME_ARGS (ts), pad, event);
138 do_push_event_post (GstTracer * self, guint64 ts, GstPad * pad, gboolean res)
140 do_log (GST_CAT_EVENT,
141 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d",
142 GST_TIME_ARGS (ts), pad, res);
146 do_pad_query_pre (GstTracer * self, guint64 ts, GstPad * pad, GstQuery * query)
148 do_log (GST_CAT_QUERY,
149 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", query=%"
150 GST_PTR_FORMAT, GST_TIME_ARGS (ts), pad, query);
154 do_pad_query_post (GstTracer * self, guint64 ts, GstPad * pad, gboolean res)
156 do_log (GST_CAT_QUERY,
157 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d",
158 GST_TIME_ARGS (ts), pad, res);
162 do_post_message_pre (GstTracer * self, guint64 ts, GstElement * elem,
165 do_log (GST_CAT_EVENT,
166 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", message=%"
167 GST_PTR_FORMAT, GST_TIME_ARGS (ts), elem, msg);
171 do_post_message_post (GstTracer * self, guint64 ts, GstElement * elem,
174 do_log (GST_CAT_EVENT,
175 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", res=%d",
176 GST_TIME_ARGS (ts), elem, res);
180 do_element_query_pre (GstTracer * self, guint64 ts, GstElement * elem,
183 do_log (GST_CAT_QUERY,
184 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", query=%"
185 GST_PTR_FORMAT, GST_TIME_ARGS (ts), elem, query);
189 do_element_query_post (GstTracer * self, guint64 ts, GstElement * elem,
192 do_log (GST_CAT_QUERY,
193 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", res=%d",
194 GST_TIME_ARGS (ts), elem, res);
198 do_element_new (GstTracer * self, guint64 ts, GstElement * elem)
200 do_log (GST_CAT_ELEMENT_FACTORY,
201 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT,
202 GST_TIME_ARGS (ts), elem);
206 do_element_add_pad (GstTracer * self, guint64 ts, GstElement * elem,
209 do_log (GST_CAT_ELEMENT_PADS,
210 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", pad=%" GST_PTR_FORMAT,
211 GST_TIME_ARGS (ts), elem, pad);
215 do_element_remove_pad (GstTracer * self, guint64 ts, GstElement * elem,
218 do_log (GST_CAT_ELEMENT_PADS,
219 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", pad=%" GST_PTR_FORMAT,
220 GST_TIME_ARGS (ts), elem, pad);
224 do_element_change_state_pre (GstTracer * self, guint64 ts, GstElement * elem,
225 GstStateChange change)
227 do_log (GST_CAT_STATES,
228 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", change=%d",
229 GST_TIME_ARGS (ts), elem, (gint) change);
233 do_element_change_state_post (GstTracer * self, guint64 ts, GstElement * elem,
234 GstStateChange change, GstStateChangeReturn res)
236 do_log (GST_CAT_STATES,
237 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", change=%d, res=%d",
238 GST_TIME_ARGS (ts), elem, (gint) change, (gint) res);
242 do_bin_add_pre (GstTracer * self, guint64 ts, GstBin * bin, GstElement * elem)
245 "%" GST_TIME_FORMAT ", bin=%" GST_PTR_FORMAT ", element=%" GST_PTR_FORMAT,
246 GST_TIME_ARGS (ts), bin, elem);
250 do_bin_add_post (GstTracer * self, guint64 ts, GstBin * bin, GstElement * elem,
254 "%" GST_TIME_FORMAT ", bin=%" GST_PTR_FORMAT ", element=%" GST_PTR_FORMAT
255 ", res=%d", GST_TIME_ARGS (ts), bin, elem, res);
259 do_bin_remove_pre (GstTracer * self, guint64 ts, GstBin * bin,
263 "%" GST_TIME_FORMAT ", bin=%" GST_PTR_FORMAT ", element=%" GST_PTR_FORMAT,
264 GST_TIME_ARGS (ts), bin, elem);
268 do_bin_remove_post (GstTracer * self, guint64 ts, GstBin * bin, gboolean res)
271 "%" GST_TIME_FORMAT ", bin=%" GST_PTR_FORMAT ", res=%d",
272 GST_TIME_ARGS (ts), bin, res);
276 do_pad_link_pre (GstTracer * self, guint64 ts, GstPad * src, GstElement * sink)
278 do_log (GST_CAT_PADS,
279 "%" GST_TIME_FORMAT ", src=%" GST_PTR_FORMAT ", sink=%" GST_PTR_FORMAT,
280 GST_TIME_ARGS (ts), src, sink);
284 do_pad_link_post (GstTracer * self, guint64 ts, GstPad * src, GstElement * sink,
285 GstPadLinkReturn res)
287 do_log (GST_CAT_PADS,
288 "%" GST_TIME_FORMAT ", src=%" GST_PTR_FORMAT ", sink=%" GST_PTR_FORMAT
289 ", res=%d", GST_TIME_ARGS (ts), src, sink, (gint) res);
293 do_pad_unlink_pre (GstTracer * self, guint64 ts, GstPad * src,
296 do_log (GST_CAT_PADS,
297 "%" GST_TIME_FORMAT ", src=%" GST_PTR_FORMAT ", sink=%" GST_PTR_FORMAT,
298 GST_TIME_ARGS (ts), src, sink);
302 do_pad_unlink_post (GstTracer * self, guint64 ts, GstPad * src,
303 GstElement * sink, gboolean res)
305 do_log (GST_CAT_PADS,
306 "%" GST_TIME_FORMAT ", src=%" GST_PTR_FORMAT ", sink=%" GST_PTR_FORMAT
307 ", res=%d", GST_TIME_ARGS (ts), src, sink, (gint) res);
313 gst_log_tracer_class_init (GstLogTracerClass * klass)
318 gst_log_tracer_init (GstLogTracer * self)
320 GstTracer *tracer = GST_TRACER (self);
322 gst_tracing_register_hook (tracer, "pad-push-pre",
323 G_CALLBACK (do_push_buffer_pre));
324 gst_tracing_register_hook (tracer, "pad-push-post",
325 G_CALLBACK (do_push_buffer_post));
326 gst_tracing_register_hook (tracer, "pad-push-list-pre",
327 G_CALLBACK (do_push_buffer_list_pre));
328 gst_tracing_register_hook (tracer, "pad-push-list-post",
329 G_CALLBACK (do_push_buffer_list_post));
330 gst_tracing_register_hook (tracer, "pad-pull-range-pre",
331 G_CALLBACK (do_pull_range_pre));
332 gst_tracing_register_hook (tracer, "pad-pull-range-post",
333 G_CALLBACK (do_pull_range_post));
334 gst_tracing_register_hook (tracer, "pad-push-event-pre",
335 G_CALLBACK (do_push_event_pre));
336 gst_tracing_register_hook (tracer, "pad-push-event-post",
337 G_CALLBACK (do_push_event_post));
338 gst_tracing_register_hook (tracer, "pad-query-pre",
339 G_CALLBACK (do_pad_query_pre));
340 gst_tracing_register_hook (tracer, "pad-query-post",
341 G_CALLBACK (do_pad_query_post));
342 gst_tracing_register_hook (tracer, "element-post-message-pre",
343 G_CALLBACK (do_post_message_pre));
344 gst_tracing_register_hook (tracer, "element-post-message-post",
345 G_CALLBACK (do_post_message_post));
346 gst_tracing_register_hook (tracer, "element-query-pre",
347 G_CALLBACK (do_element_query_pre));
348 gst_tracing_register_hook (tracer, "element-query-post",
349 G_CALLBACK (do_element_query_post));
350 gst_tracing_register_hook (tracer, "element-new",
351 G_CALLBACK (do_element_new));
352 gst_tracing_register_hook (tracer, "element-add-pad",
353 G_CALLBACK (do_element_add_pad));
354 gst_tracing_register_hook (tracer, "element-remove-pad",
355 G_CALLBACK (do_element_remove_pad));
356 gst_tracing_register_hook (tracer, "element-change-state-pre",
357 G_CALLBACK (do_element_change_state_pre));
358 gst_tracing_register_hook (tracer, "element-change-state-post",
359 G_CALLBACK (do_element_change_state_post));
360 gst_tracing_register_hook (tracer, "bin-add-pre",
361 G_CALLBACK (do_bin_add_pre));
362 gst_tracing_register_hook (tracer, "bin-add-post",
363 G_CALLBACK (do_bin_add_post));
364 gst_tracing_register_hook (tracer, "bin-remove-pre",
365 G_CALLBACK (do_bin_remove_pre));
366 gst_tracing_register_hook (tracer, "bin-remove-post",
367 G_CALLBACK (do_bin_remove_post));
368 gst_tracing_register_hook (tracer, "pad-link-pre",
369 G_CALLBACK (do_pad_link_pre));
370 gst_tracing_register_hook (tracer, "pad-link-post",
371 G_CALLBACK (do_pad_link_post));
372 gst_tracing_register_hook (tracer, "pad-unlink-pre",
373 G_CALLBACK (do_pad_unlink_pre));
374 gst_tracing_register_hook (tracer, "pad-unlink-post",
375 G_CALLBACK (do_pad_unlink_post));