tracer: add the hook-id to the invoke signature
[platform/upstream/gstreamer.git] / plugins / tracers / gstlog.c
1 /* GStreamer
2  * Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
3  *
4  * gstlog.c: tracing module that logs events
5  *
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.
10  *
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.
15  *
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.
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #  include "config.h"
24 #endif
25
26 #include "gstlog.h"
27
28 GST_DEBUG_CATEGORY_STATIC (gst_log_debug);
29 #define GST_CAT_DEFAULT gst_log_debug
30
31 #define _do_init \
32     GST_DEBUG_CATEGORY_INIT (gst_log_debug, "log", 0, "log tracer");
33 #define gst_log_tracer_parent_class parent_class
34 G_DEFINE_TYPE_WITH_CODE (GstLogTracer, gst_log_tracer, GST_TYPE_TRACER,
35     _do_init);
36
37 static void gst_log_tracer_invoke (GstTracerHookId id, GstStructure * s);
38
39 static void
40 gst_log_tracer_class_init (GstLogTracerClass * klass)
41 {
42   GstTracerClass *gst_tracer_class = GST_TRACER_CLASS (klass);
43
44   gst_tracer_class->invoke = gst_log_tracer_invoke;
45 }
46
47 static void
48 gst_log_tracer_init (GstLogTracer * self)
49 {
50   g_object_set (self, "mask", GST_TRACER_HOOK_ALL, NULL);
51 }
52
53 static void
54 gst_log_tracer_invoke (GstTracerHookId id, GstStructure * s)
55 {
56   gchar *str = gst_structure_to_string (s);
57   /* TODO(ensonic): log to different categories depending on 'id' */
58   GST_TRACE ("%s", str);
59   g_free (str);
60 }