mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
tracers: add a logging helper to remove identical copies from the tracers
This commit is contained in:
parent
635a4b5c00
commit
7dfc0a8ead
5 changed files with 31 additions and 50 deletions
|
@ -299,4 +299,18 @@ gst_tracer_dispatch (GstTracerHookId hid, GstTracerMessageId mid, ...)
|
|||
}
|
||||
}
|
||||
|
||||
/* tracing module helpers */
|
||||
|
||||
void
|
||||
gst_tracer_log_trace (GstStructure * s)
|
||||
{
|
||||
gchar *data;
|
||||
|
||||
// TODO(ensonic): use a GVariant?
|
||||
data = gst_structure_to_string (s);
|
||||
GST_TRACE ("%s", data);
|
||||
g_free (data);
|
||||
gst_structure_free (s);
|
||||
}
|
||||
|
||||
#endif /* GST_DISABLE_GST_DEBUG */
|
||||
|
|
|
@ -118,9 +118,18 @@ GType gst_tracer_get_type (void);
|
|||
void _priv_gst_tracer_init (void);
|
||||
void _priv_gst_tracer_deinit (void);
|
||||
|
||||
/* tracing modules */
|
||||
|
||||
gboolean gst_tracer_register (GstPlugin * plugin, const gchar * name, GType type);
|
||||
|
||||
/* tracing helpers */
|
||||
|
||||
void gst_tracer_dispatch (GstTracerHookId hid, GstTracerMessageId mid, ...);
|
||||
|
||||
/* tracing module helpers */
|
||||
|
||||
void gst_tracer_log_trace (GstStructure * s);
|
||||
|
||||
extern gboolean _priv_tracer_enabled;
|
||||
extern GList *_priv_tracers[GST_TRACER_HOOK_ID_LAST];
|
||||
|
||||
|
|
|
@ -38,20 +38,6 @@ static GQuark latency_probe_id;
|
|||
static GQuark latency_probe_pad;
|
||||
static GQuark latency_probe_ts;
|
||||
|
||||
/* logging */
|
||||
|
||||
static void
|
||||
log_trace (GstStructure * s)
|
||||
{
|
||||
gchar *data;
|
||||
|
||||
// TODO(ensonic): use a GVariant?
|
||||
data = gst_structure_to_string (s);
|
||||
GST_TRACE ("%s", data);
|
||||
g_free (data);
|
||||
gst_structure_free (s);
|
||||
}
|
||||
|
||||
/* data helpers */
|
||||
|
||||
/*
|
||||
|
@ -177,7 +163,7 @@ do_push_event_pre (GstLatencyTracer * self, va_list var_args)
|
|||
to = g_strdup_printf ("%s_%s", GST_DEBUG_PAD_NAME (peer_pad));
|
||||
|
||||
/* TODO(ensonic): report format is still unstable */
|
||||
log_trace (gst_structure_new ("latency",
|
||||
gst_tracer_log_trace (gst_structure_new ("latency",
|
||||
"from", G_TYPE_STRING, from,
|
||||
"to", G_TYPE_STRING, to,
|
||||
"time", G_TYPE_UINT64, GST_CLOCK_DIFF (origin_ts, ts), NULL));
|
||||
|
|
|
@ -48,20 +48,6 @@ typedef struct
|
|||
static void gst_rusage_tracer_invoke (GstTracer * self, GstTracerHookId id,
|
||||
GstTracerMessageId mid, va_list var_args);
|
||||
|
||||
/* logging */
|
||||
|
||||
static void
|
||||
log_trace (GstStructure * s)
|
||||
{
|
||||
gchar *data;
|
||||
|
||||
// TODO(ensonic): use a GVariant?
|
||||
data = gst_structure_to_string (s);
|
||||
GST_TRACE ("%s", data);
|
||||
g_free (data);
|
||||
gst_structure_free (s);
|
||||
}
|
||||
|
||||
/* data helper */
|
||||
|
||||
static void
|
||||
|
@ -146,7 +132,7 @@ gst_rusage_tracer_invoke (GstTracer * obj, GstTracerHookId hid,
|
|||
*/
|
||||
cpuload =
|
||||
(guint) gst_util_uint64_scale (tusersys, G_GINT64_CONSTANT (100), treal);
|
||||
log_trace (gst_structure_new ("rusage", "ts", G_TYPE_UINT64, treal, "thread-id", G_TYPE_UINT, GPOINTER_TO_UINT (thread_id), "cpuload", G_TYPE_UINT, cpuload, "treal", G_TYPE_UINT64, stats->treal, /* time in thread */
|
||||
gst_tracer_log_trace (gst_structure_new ("rusage", "ts", G_TYPE_UINT64, treal, "thread-id", G_TYPE_UINT, GPOINTER_TO_UINT (thread_id), "cpuload", G_TYPE_UINT, cpuload, "treal", G_TYPE_UINT64, stats->treal, /* time in thread */
|
||||
"tsum", G_TYPE_UINT64, tusersys, /* time in process */
|
||||
NULL));
|
||||
}
|
||||
|
|
|
@ -62,20 +62,6 @@ typedef struct
|
|||
guint parent_ix;
|
||||
} GstElementStats;
|
||||
|
||||
/* logging */
|
||||
|
||||
static void
|
||||
log_trace (GstStructure * s)
|
||||
{
|
||||
gchar *data;
|
||||
|
||||
// TODO(ensonic): use a GVariant?
|
||||
data = gst_structure_to_string (s);
|
||||
GST_TRACE ("%s", data);
|
||||
g_free (data);
|
||||
gst_structure_free (s);
|
||||
}
|
||||
|
||||
/* data helper */
|
||||
|
||||
static GstElementStats no_elem_stats = { 0, };
|
||||
|
@ -93,7 +79,7 @@ fill_element_stats (GstStatsTracer * self, GstElement * element)
|
|||
static void
|
||||
log_new_element_stats (GstElementStats * stats, GstElement * element)
|
||||
{
|
||||
log_trace (gst_structure_new ("new-element",
|
||||
gst_tracer_log_trace (gst_structure_new ("new-element",
|
||||
"ix", G_TYPE_UINT, stats->index,
|
||||
"parent-ix", G_TYPE_UINT, stats->parent_ix,
|
||||
"name", G_TYPE_STRING, GST_OBJECT_NAME (element),
|
||||
|
@ -190,7 +176,7 @@ fill_pad_stats (GstStatsTracer * self, GstPad * pad)
|
|||
static void
|
||||
log_new_pad_stats (GstPadStats * stats, GstPad * pad)
|
||||
{
|
||||
log_trace (gst_structure_new ("new-pad",
|
||||
gst_tracer_log_trace (gst_structure_new ("new-pad",
|
||||
"ix", G_TYPE_UINT, stats->index,
|
||||
"parent-ix", G_TYPE_UINT, stats->parent_ix,
|
||||
"name", G_TYPE_STRING, GST_OBJECT_NAME (pad),
|
||||
|
@ -252,7 +238,7 @@ do_buffer_stats (GstStatsTracer * self, GstPad * this_pad,
|
|||
GstElementStats *that_elem_stats = get_element_stats (self, that_elem);
|
||||
|
||||
/* TODO(ensonic): need a quark-table (shared with the tracer-front-ends?) */
|
||||
log_trace (gst_structure_new ("buffer",
|
||||
gst_tracer_log_trace (gst_structure_new ("buffer",
|
||||
"ts", G_TYPE_UINT64, elapsed,
|
||||
"pad-ix", G_TYPE_UINT, this_pad_stats->index,
|
||||
"elem-ix", G_TYPE_UINT, this_elem_stats->index,
|
||||
|
@ -480,7 +466,7 @@ do_push_event_pre (GstStatsTracer * self, va_list var_args)
|
|||
GstPadStats *pad_stats = get_pad_stats (self, pad);
|
||||
|
||||
elem_stats->last_ts = ts;
|
||||
log_trace (gst_structure_new ("event",
|
||||
gst_tracer_log_trace (gst_structure_new ("event",
|
||||
"ts", G_TYPE_UINT64, ts,
|
||||
"pad-ix", G_TYPE_UINT, pad_stats->index,
|
||||
"elem-ix", G_TYPE_UINT, elem_stats->index,
|
||||
|
@ -505,7 +491,7 @@ do_post_message_pre (GstStatsTracer * self, va_list var_args)
|
|||
GstElementStats *stats = get_element_stats (self, elem);
|
||||
|
||||
stats->last_ts = ts;
|
||||
log_trace (gst_structure_new ("message",
|
||||
gst_tracer_log_trace (gst_structure_new ("message",
|
||||
"ts", G_TYPE_UINT64, ts,
|
||||
"elem-ix", G_TYPE_UINT, stats->index,
|
||||
"name", G_TYPE_STRING, GST_MESSAGE_TYPE_NAME (msg), NULL));
|
||||
|
@ -529,7 +515,7 @@ do_query_pre (GstStatsTracer * self, va_list var_args)
|
|||
GstElementStats *stats = get_element_stats (self, elem);
|
||||
|
||||
stats->last_ts = ts;
|
||||
log_trace (gst_structure_new ("query",
|
||||
gst_tracer_log_trace (gst_structure_new ("query",
|
||||
"ts", G_TYPE_UINT64, ts,
|
||||
"elem-ix", G_TYPE_UINT, stats->index,
|
||||
"name", G_TYPE_STRING, GST_QUERY_TYPE_NAME (qry), NULL));
|
||||
|
|
Loading…
Reference in a new issue