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_BUFFER);
39 GST_DEBUG_CATEGORY_STATIC (GST_CAT_BUFFER_LIST);
40 GST_DEBUG_CATEGORY_STATIC (GST_CAT_EVENT);
41 GST_DEBUG_CATEGORY_STATIC (GST_CAT_MESSAGE);
42 GST_DEBUG_CATEGORY_STATIC (GST_CAT_QUERY);
45 GST_DEBUG_CATEGORY_INIT (gst_log_debug, "log", 0, "log tracer"); \
46 GST_DEBUG_CATEGORY_GET (GST_CAT_BUFFER, "GST_BUFFER"); \
47 GST_DEBUG_CATEGORY_GET (GST_CAT_BUFFER_LIST, "GST_BUFFER_LIST"); \
48 GST_DEBUG_CATEGORY_GET (GST_CAT_EVENT, "GST_EVENT"); \
49 GST_DEBUG_CATEGORY_GET (GST_CAT_MESSAGE, "GST_MESSAGE"); \
50 GST_DEBUG_CATEGORY_GET (GST_CAT_QUERY, "query");
51 #define gst_log_tracer_parent_class parent_class
52 G_DEFINE_TYPE_WITH_CODE (GstLogTracer, gst_log_tracer, GST_TYPE_TRACER,
56 do_log (GstDebugCategory * cat, const char *fmt, ...)
60 va_start (var_args, fmt);
61 gst_debug_log_valist (cat, GST_LEVEL_TRACE, "", "", 0, NULL, fmt, var_args);
66 do_push_buffer_pre (GstTracer * self, guint64 ts, GstPad * pad,
69 do_log (GST_CAT_BUFFER,
70 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", buffer=%" GST_PTR_FORMAT,
71 GST_TIME_ARGS (ts), pad, buffer);
75 do_push_buffer_post (GstTracer * self, guint64 ts, GstPad * pad,
78 do_log (GST_CAT_BUFFER,
79 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d",
80 GST_TIME_ARGS (ts), pad, res);
84 do_push_buffer_list_pre (GstTracer * self, guint64 ts, GstPad * pad,
87 do_log (GST_CAT_BUFFER_LIST,
88 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", list=%p",
89 GST_TIME_ARGS (ts), pad, list);
93 do_push_buffer_list_post (GstTracer * self, guint64 ts, GstPad * pad,
96 do_log (GST_CAT_BUFFER_LIST,
97 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d",
98 GST_TIME_ARGS (ts), pad, res);
102 do_pull_range_pre (GstTracer * self, guint64 ts, GstPad * pad, guint64 offset,
105 do_log (GST_CAT_BUFFER,
106 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", offset=%" G_GUINT64_FORMAT
107 ", size=%u", GST_TIME_ARGS (ts), pad, offset, size);
111 do_pull_range_post (GstTracer * self, guint64 ts, GstPad * pad,
112 GstBuffer * buffer, GstFlowReturn res)
114 do_log (GST_CAT_BUFFER,
115 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", buffer=%" GST_PTR_FORMAT
116 ", res=%d", GST_TIME_ARGS (ts), pad, buffer, res);
120 do_push_event_pre (GstTracer * self, guint64 ts, GstPad * pad, GstEvent * event)
122 do_log (GST_CAT_EVENT,
123 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", event=%" GST_PTR_FORMAT,
124 GST_TIME_ARGS (ts), pad, event);
128 do_push_event_post (GstTracer * self, guint64 ts, GstPad * pad, gboolean res)
130 do_log (GST_CAT_EVENT,
131 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d",
132 GST_TIME_ARGS (ts), pad, res);
136 do_post_message_pre (GstTracer * self, guint64 ts, GstElement * elem,
139 do_log (GST_CAT_EVENT,
140 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", message=%"
141 GST_PTR_FORMAT, GST_TIME_ARGS (ts), elem, msg);
145 do_post_message_post (GstTracer * self, guint64 ts, GstElement * elem,
148 do_log (GST_CAT_EVENT,
149 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", res=%d",
150 GST_TIME_ARGS (ts), elem, res);
154 do_query_pre (GstTracer * self, guint64 ts, GstElement * elem, GstQuery * query)
156 do_log (GST_CAT_QUERY,
157 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", query=%"
158 GST_PTR_FORMAT, GST_TIME_ARGS (ts), elem, query);
162 do_query_post (GstTracer * self, guint64 ts, GstElement * elem, gboolean res)
164 do_log (GST_CAT_QUERY,
165 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", res=%d",
166 GST_TIME_ARGS (ts), elem, res);
173 gst_log_tracer_class_init (GstLogTracerClass * klass)
178 gst_log_tracer_init (GstLogTracer * self)
180 GstTracer *tracer = GST_TRACER (self);
182 gst_tracing_register_hook (tracer, "pad-push-pre",
183 G_CALLBACK (do_push_buffer_pre));
184 gst_tracing_register_hook (tracer, "pad-push-post",
185 G_CALLBACK (do_push_buffer_post));
186 gst_tracing_register_hook (tracer, "pad-push-list-pre",
187 G_CALLBACK (do_push_buffer_list_pre));
188 gst_tracing_register_hook (tracer, "pad-push-list-post",
189 G_CALLBACK (do_push_buffer_list_post));
190 gst_tracing_register_hook (tracer, "pad-pull-range-pre",
191 G_CALLBACK (do_pull_range_pre));
192 gst_tracing_register_hook (tracer, "pad-pull-range-post",
193 G_CALLBACK (do_pull_range_post));
194 gst_tracing_register_hook (tracer, "pad-push-event-pre",
195 G_CALLBACK (do_push_event_pre));
196 gst_tracing_register_hook (tracer, "pad-push-event-post",
197 G_CALLBACK (do_push_event_post));
198 gst_tracing_register_hook (tracer, "element-post-message-pre",
199 G_CALLBACK (do_post_message_pre));
200 gst_tracing_register_hook (tracer, "element-post-message-post",
201 G_CALLBACK (do_post_message_post));
202 gst_tracing_register_hook (tracer, "element-query-pre",
203 G_CALLBACK (do_query_pre));
204 gst_tracing_register_hook (tracer, "element-query-post",
205 G_CALLBACK (do_query_post));