Class (GI Struct)

Gst-1.0GstLogContextAbstractSince 1.28

A context for controlling logging behavior, for example to handle logging once or periodic logging, avoiding to spam the terminal with the same log message multiple times.

// At global/file scope:
GST_LOG_CONTEXT_STATIC_DEFINE(my_context, GST_LOG_CONTEXT_FLAG_THROTTLE, );
#define MY_CONTEXT GST_LOG_CONTEXT_LAZY_INIT(my_context)

// Then in code:
GST_CTX_INFO(MY_CONTEXT, "This will only appear once per file/line");

For messages that should be logged periodically (e.g., maximum once per minute):

// At global/file scope:
GST_LOG_CONTEXT_STATIC_DEFINE(my_periodic_context, GST_LOG_CONTEXT_FLAG_THROTTLE,
GST_LOG_CONTEXT_BUILDER_SET_INTERVAL(60 * GST_SECOND);
);
#define MY_PERIODIC_CONTEXT GST_LOG_CONTEXT_LAZY_INIT(my_periodic_context)

// Then in code:
GST_CTX_INFO(MY_PERIODIC_CONTEXT, "This appears once per minute");

By default, a message's hash is determined by the file name, object pointer, and format string. You can customize this with builder operations:

// Ignore the object pointer when determining message hash (with throttling)
GST_LOG_CONTEXT_STATIC_DEFINE(obj_independent_ctx, GST_LOG_CONTEXT_FLAG_THROTTLE,
GST_LOG_CONTEXT_BUILDER_SET_HASH_FLAGS(GST_LOG_CONTEXT_IGNORE_OBJECT);
);

// Use a custom category (without throttling)
GST_LOG_CONTEXT_STATIC_DEFINE(custom_cat_ctx, GST_LOG_CONTEXT_FLAG_NONE,
GST_LOG_CONTEXT_BUILDER_SET_CATEGORY(my_category);
);

1.28

Index

Constructors

Properties

Methods

Constructors

Properties

$gtype: GType<LogContext>

Methods