2013-10-24 12:47:48 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
|
|
|
|
*
|
|
|
|
* gstlog.c: tracing module that logs events
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gstlog.h"
|
|
|
|
|
2014-07-16 07:22:14 +00:00
|
|
|
#include <gst/printf/printf.h>
|
|
|
|
|
2013-10-24 12:47:48 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_log_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_log_debug
|
2013-10-30 07:04:27 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_BUFFER);
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_BUFFER_LIST);
|
2014-07-16 07:22:14 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_EVENT);
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_MESSAGE);
|
2013-10-24 12:47:48 +00:00
|
|
|
|
|
|
|
#define _do_init \
|
2013-10-30 07:04:27 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_log_debug, "log", 0, "log tracer"); \
|
|
|
|
GST_DEBUG_CATEGORY_GET (GST_CAT_BUFFER, "GST_BUFFER"); \
|
2014-07-16 07:22:14 +00:00
|
|
|
GST_DEBUG_CATEGORY_GET (GST_CAT_BUFFER_LIST, "GST_BUFFER_LIST"); \
|
|
|
|
GST_DEBUG_CATEGORY_GET (GST_CAT_EVENT, "GST_EVENT"); \
|
|
|
|
GST_DEBUG_CATEGORY_GET (GST_CAT_MESSAGE, "GST_MESSAGE");
|
2013-10-24 12:47:48 +00:00
|
|
|
#define gst_log_tracer_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstLogTracer, gst_log_tracer, GST_TYPE_TRACER,
|
|
|
|
_do_init);
|
|
|
|
|
2013-10-27 19:43:25 +00:00
|
|
|
static void gst_log_tracer_invoke (GstTracer * self, GstTracerHookId id,
|
2013-10-28 20:59:19 +00:00
|
|
|
GstTracerMessageId mid, va_list var_args);
|
2013-10-24 12:47:48 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_log_tracer_class_init (GstLogTracerClass * klass)
|
|
|
|
{
|
|
|
|
GstTracerClass *gst_tracer_class = GST_TRACER_CLASS (klass);
|
|
|
|
|
|
|
|
gst_tracer_class->invoke = gst_log_tracer_invoke;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_log_tracer_init (GstLogTracer * self)
|
|
|
|
{
|
|
|
|
g_object_set (self, "mask", GST_TRACER_HOOK_ALL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-10-28 20:59:19 +00:00
|
|
|
gst_log_tracer_invoke (GstTracer * self, GstTracerHookId hid,
|
|
|
|
GstTracerMessageId mid, va_list var_args)
|
2013-10-24 12:47:48 +00:00
|
|
|
{
|
2013-10-30 07:04:27 +00:00
|
|
|
const gchar *fmt = NULL;
|
|
|
|
GstDebugCategory *cat = GST_CAT_DEFAULT;
|
2013-10-28 20:59:19 +00:00
|
|
|
guint64 ts = va_arg (var_args, guint64);
|
2013-10-30 07:04:27 +00:00
|
|
|
|
|
|
|
/* TODO(ensonic): log to different categories depending on 'mid'
|
|
|
|
* GST_TRACER_HOOK_ID_QUERIES -> (static category)
|
2013-10-27 16:05:52 +00:00
|
|
|
* GST_TRACER_HOOK_ID_TOPLOGY -> ?
|
|
|
|
*/
|
2013-10-30 07:04:27 +00:00
|
|
|
switch (mid) {
|
|
|
|
case GST_TRACER_MESSAGE_ID_PAD_PUSH_PRE:
|
|
|
|
cat = GST_CAT_BUFFER;
|
|
|
|
fmt = "pad=%" GST_PTR_FORMAT ", buffer=%" GST_PTR_FORMAT;
|
|
|
|
break;
|
|
|
|
case GST_TRACER_MESSAGE_ID_PAD_PUSH_POST:
|
|
|
|
cat = GST_CAT_BUFFER;
|
|
|
|
fmt = "pad=%" GST_PTR_FORMAT ", res=%d";
|
|
|
|
break;
|
|
|
|
case GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_PRE:
|
|
|
|
cat = GST_CAT_BUFFER_LIST;
|
|
|
|
fmt = "pad=%" GST_PTR_FORMAT ", list=%p";
|
|
|
|
break;
|
|
|
|
case GST_TRACER_MESSAGE_ID_PAD_PUSH_LIST_POST:
|
|
|
|
cat = GST_CAT_BUFFER_LIST;
|
|
|
|
fmt = "pad=%" GST_PTR_FORMAT ", res=%d";
|
|
|
|
break;
|
2014-07-16 07:22:14 +00:00
|
|
|
case GST_TRACER_MESSAGE_ID_PAD_PULL_RANGE_PRE:
|
|
|
|
cat = GST_CAT_BUFFER;
|
|
|
|
fmt = "pad=%" GST_PTR_FORMAT ", offset=%" G_GUINT64_FORMAT ", size=%u";
|
|
|
|
break;
|
|
|
|
case GST_TRACER_MESSAGE_ID_PAD_PULL_RANGE_POST:
|
|
|
|
cat = GST_CAT_BUFFER;
|
|
|
|
fmt = "pad=%" GST_PTR_FORMAT ", buffer=%" GST_PTR_FORMAT ", res=%d";
|
|
|
|
break;
|
|
|
|
case GST_TRACER_MESSAGE_ID_PAD_PUSH_EVENT_PRE:
|
|
|
|
cat = GST_CAT_EVENT;
|
|
|
|
fmt = "pad=%" GST_PTR_FORMAT ", event=%" GST_PTR_FORMAT;
|
|
|
|
break;
|
|
|
|
case GST_TRACER_MESSAGE_ID_PAD_PUSH_EVENT_POST:
|
|
|
|
cat = GST_CAT_EVENT;
|
|
|
|
fmt = "pad=%" GST_PTR_FORMAT ", res=%d";
|
|
|
|
break;
|
|
|
|
case GST_TRACER_MESSAGE_ID_ELEMENT_POST_MESSAGE_PRE:
|
|
|
|
cat = GST_CAT_MESSAGE;
|
|
|
|
fmt = "element=%" GST_PTR_FORMAT ", message=%" GST_PTR_FORMAT;
|
|
|
|
break;
|
|
|
|
case GST_TRACER_MESSAGE_ID_ELEMENT_POST_MESSAGE_POST:
|
|
|
|
cat = GST_CAT_MESSAGE;
|
|
|
|
fmt = "element=%" GST_PTR_FORMAT ", res=%d";
|
|
|
|
break;
|
|
|
|
case GST_TRACER_MESSAGE_ID_ELEMENT_QUERY_PRE:
|
|
|
|
fmt = "element=%" GST_PTR_FORMAT ", query=%" GST_PTR_FORMAT;
|
|
|
|
break;
|
|
|
|
case GST_TRACER_MESSAGE_ID_ELEMENT_QUERY_POST:
|
|
|
|
fmt = "element=%" GST_PTR_FORMAT ", res=%d";
|
|
|
|
break;
|
2013-10-30 07:04:27 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (fmt) {
|
2014-07-16 07:22:14 +00:00
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
__gst_vasprintf (&str, fmt, var_args);
|
2013-10-30 07:04:27 +00:00
|
|
|
GST_CAT_TRACE (cat, "[%d,%d] %" GST_TIME_FORMAT ", %s",
|
|
|
|
hid, mid, GST_TIME_ARGS (ts), str);
|
|
|
|
g_free (str);
|
|
|
|
} else {
|
|
|
|
GST_CAT_TRACE (cat, "[%d,%d] %" GST_TIME_FORMAT,
|
|
|
|
hid, mid, GST_TIME_ARGS (ts));
|
|
|
|
}
|
2013-10-24 12:47:48 +00:00
|
|
|
}
|