log-object: Add possibility to reset logger id

Logger id (the one generated from build_id interface method and owner_id
property) is generated and cached the first time it is required, further
uses just return the cached value.

Add a cache reset method so if the interface implementer knows that its
logger id could have changed it could force its re-generation.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
This commit is contained in:
Maciej S. Szmigiero
2025-05-23 18:46:32 -05:00
committed by Dan Williams
parent 39f4cf77f2
commit 42ead88266
2 changed files with 12 additions and 0 deletions
+11
View File
@@ -81,6 +81,17 @@ mm_log_object_set_owner_id (MMLogObject *self,
priv = get_private (self);
g_free (priv->owner_id);
priv->owner_id = g_strdup (owner_id);
mm_log_object_reset_id (self);
}
void
mm_log_object_reset_id (MMLogObject *self)
{
Private *priv;
priv = get_private (self);
g_clear_pointer (&priv->id, g_free);
}
static void
+1
View File
@@ -34,5 +34,6 @@ struct _MMLogObjectInterface
const gchar *mm_log_object_get_id (MMLogObject *self);
void mm_log_object_set_owner_id (MMLogObject *self,
const gchar *owner_id);
void mm_log_object_reset_id (MMLogObject *self);
#endif /* MM_LOG_OBJECT_H */