Page MenuHomeClusterLabs Projects

Use glib logging domain
Closed (Merged)Public

Assigned To
Authored By
kgaillot
Jul 1 2024, 1:06 PM
Tags
  • Restricted Project
  • Restricted Project
  • Restricted Project
Referenced Files
None
Subscribers

Description

Pacemaker should define LOG_DOMAIN internally and use g_log_set_handler() instead of g_log_set_default_handler().

This would allow external apps to link with Pacemaker libraries and still be able to use their own default glib log handler.

Event Timeline

kgaillot triaged this task as Normal priority.Jul 1 2024, 1:06 PM
kgaillot created this task.
kgaillot created this object with edit policy "Restricted Project (Project)".
clumens changed the task status from Open to WIP.Aug 16 2024, 2:47 PM
clumens claimed this task.

Related, we have this in logging.c:

/* and for good measure... - this enum is a bit field (!) */
g_log_set_always_fatal((GLogLevelFlags) 0); /*value out of range */

However, the glib docs say this:

Libraries should not call this function, as it affects all messages logged by a process, including those from other libraries.

Which leads me to believe we should remove this from logging.c and if our command line tools want to do this, they should add the call themselves. I'm not sure if there would be unintended consequences, however.

In T837#13290, @clumens wrote:
g_log_set_always_fatal((GLogLevelFlags) 0); /*value out of range */

This disables glib aborting after an error message.

Which leads me to believe we should remove this from logging.c and if our command line tools want to do this, they should add the call themselves. I'm not sure if there would be unintended consequences, however.

It looks like we can replace it with g_log_set_fatal_mask() once we define our own log domain.

This disables glib aborting after an error message.

Right, hence the unintended consequences if suddenly messages can be fatal.

It looks like we can replace it with g_log_set_fatal_mask() once we define our own log domain.

This is probably a good way to do it. We can still avoid aborting from all pacemaker logging, but if the tool links against some other library, we're not messing with whatever settings that library provides.

kgaillot added a project: Restricted Project.Oct 2 2024, 11:19 AM