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 *format, va_list var_args)
58 gst_debug_log_valist (cat, GST_LEVEL_TRACE, "", "", 0, NULL,
63 do_push_buffer_pre (GstTracer * self, va_list var_args)
65 do_log (GST_CAT_BUFFER,
66 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", buffer=%" GST_PTR_FORMAT,
71 do_push_buffer_post (GstTracer * self, va_list var_args)
73 do_log (GST_CAT_BUFFER,
74 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d", var_args);
78 do_push_buffer_list_pre (GstTracer * self, va_list var_args)
80 do_log (GST_CAT_BUFFER_LIST,
81 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", list=%p", var_args);
85 do_push_buffer_list_post (GstTracer * self, va_list var_args)
87 do_log (GST_CAT_BUFFER_LIST,
88 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d", var_args);
92 do_pull_range_pre (GstTracer * self, va_list var_args)
94 do_log (GST_CAT_BUFFER,
95 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", offset=%" G_GUINT64_FORMAT
96 ", size=%u", var_args);
100 do_pull_range_post (GstTracer * self, va_list var_args)
102 do_log (GST_CAT_BUFFER,
103 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", buffer=%" GST_PTR_FORMAT
104 ", res=%d", var_args);
108 do_push_event_pre (GstTracer * self, va_list var_args)
110 do_log (GST_CAT_EVENT,
111 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", event=%" GST_PTR_FORMAT,
116 do_push_event_post (GstTracer * self, va_list var_args)
118 do_log (GST_CAT_EVENT,
119 "%" GST_TIME_FORMAT ", pad=%" GST_PTR_FORMAT ", res=%d", var_args);
123 do_post_message_pre (GstTracer * self, va_list var_args)
125 do_log (GST_CAT_EVENT,
126 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", message=%"
127 GST_PTR_FORMAT, var_args);
131 do_post_message_post (GstTracer * self, va_list var_args)
133 do_log (GST_CAT_EVENT,
134 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", res=%d", var_args);
138 do_query_pre (GstTracer * self, va_list var_args)
140 do_log (GST_CAT_QUERY,
141 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", query=%"
142 GST_PTR_FORMAT, var_args);
146 do_query_post (GstTracer * self, va_list var_args)
148 do_log (GST_CAT_QUERY,
149 "%" GST_TIME_FORMAT ", element=%" GST_PTR_FORMAT ", res=%d", var_args);
156 gst_log_tracer_class_init (GstLogTracerClass * klass)
161 gst_log_tracer_init (GstLogTracer * self)
163 GstTracer *tracer = GST_TRACER (self);
165 gst_tracer_register_hook (tracer, "pad-push-pre", do_push_buffer_pre);
166 gst_tracer_register_hook (tracer, "pad-push-post", do_push_buffer_post);
167 gst_tracer_register_hook (tracer, "pad-push-list-pre",
168 do_push_buffer_list_pre);
169 gst_tracer_register_hook (tracer, "pad-push-list-post",
170 do_push_buffer_list_post);
171 gst_tracer_register_hook (tracer, "pad-pull-range-pre", do_pull_range_pre);
172 gst_tracer_register_hook (tracer, "pad-pull-range-post", do_pull_range_post);
173 gst_tracer_register_hook (tracer, "pad-push-event-pre", do_push_event_pre);
174 gst_tracer_register_hook (tracer, "pad-push-event-post", do_push_event_post);
175 gst_tracer_register_hook (tracer, "element-post-message-pre",
176 do_post_message_pre);
177 gst_tracer_register_hook (tracer, "element-post-message-post",
178 do_post_message_post);
179 gst_tracer_register_hook (tracer, "element-query-pre", do_query_pre);
180 gst_tracer_register_hook (tracer, "element-query-post", do_query_post);