]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Feature-redfish: enabling libredfish logging on collectd debug mode (#3907)
authorMathieu STOFFEL <mathieu.stoffel@atos.net>
Mon, 27 Sep 2021 14:37:05 +0000 (16:37 +0200)
committerGitHub <noreply@github.com>
Mon, 27 Sep 2021 14:37:05 +0000 (16:37 +0200)
Changelog: enabling libredfish logging on collectd debug mode

In order for `libredfish` to log internal information, which are more
than useful to debugging purposes, a printing function has to be
registered through a hook : a global function pointer named `gDebugFunc`.

The `plugin_log` function is registered as the logging function through
the aforementioned hook by the `redfish_init` function, when the
`--enable-debug` option is specified to the `configure` script.

src/redfish.c

index 947fb392e42e8e6c224a8916464776dc456a7b6d..8cfbb2924fdb9a74c6d1c25363d78eca633806e5 100644 (file)
@@ -113,6 +113,10 @@ static int redfish_validate_config(void);
 static void *redfish_worker_thread(void __attribute__((unused)) * args);
 
 #if COLLECT_DEBUG
+/* Hook exposed by the libredfish library to define a printing function
+ * dedicated to logging purposes: */
+extern libRedfishDebugFunc gDebugFunc;
+
 static void redfish_print_config(void) {
   DEBUG(PLUGIN_NAME ": ====================CONFIGURATION====================");
   DEBUG(PLUGIN_NAME ": SERVICES: %d", llist_size(ctx.services));
@@ -193,6 +197,10 @@ static void redfish_job_destroy(redfish_job_t *job) {
 
 static int redfish_init(void) {
 #if COLLECT_DEBUG
+  /* Registering plugin_log as the printing function dedicated to logging
+   * purposes within libredfish: */
+  gDebugFunc = plugin_log;
+
   redfish_print_config();
 #endif
   int ret = redfish_validate_config();