[pve-devel] [PATCH cluster 2/3] pmxcfs: set log domain in more places
Fabian Grünbichler
f.gruenbichler at proxmox.com
Thu Oct 1 10:53:25 CEST 2020
so that we can default to the set log domain instead of 'unknown' in
cfs_debug/message/critical. used log domain values are copied from old
G_LOG_DOMAIN behaviour.
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
data/src/cfs-utils.h | 6 +++---
data/src/cfs-plug-func.c | 2 ++
data/src/cfs-plug-link.c | 2 ++
data/src/cfs-plug-memdb.c | 2 ++
data/src/cfs-plug.c | 2 ++
data/src/cfs-utils.c | 12 ++++++------
data/src/confdb.c | 1 +
data/src/database.c | 1 +
data/src/dcdb.c | 1 +
data/src/dfsm.c | 14 +++++++++-----
data/src/logger.c | 2 ++
data/src/loop.c | 1 +
data/src/memdb.c | 2 ++
data/src/pmxcfs.c | 2 ++
data/src/quorum.c | 1 +
data/src/server.c | 1 +
data/src/status.c | 1 +
17 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/data/src/cfs-utils.h b/data/src/cfs-utils.h
index 51cfef0..ac5f6eb 100644
--- a/data/src/cfs-utils.h
+++ b/data/src/cfs-utils.h
@@ -100,7 +100,7 @@ void ipc_log_fn(
#define cfs_debug(...) G_STMT_START { \
if (cfs.debug) \
- cfs_log(CFS_LOG_UNKNOWN, G_LOG_LEVEL_DEBUG, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__); \
+ cfs_log(CFS_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__); \
} G_STMT_END
#define cfs_dom_debug(domain, ...) G_STMT_START { \
@@ -108,9 +108,9 @@ void ipc_log_fn(
cfs_log(domain, G_LOG_LEVEL_DEBUG, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__); \
} G_STMT_END
-#define cfs_critical(...) cfs_log(CFS_LOG_UNKNOWN, G_LOG_LEVEL_CRITICAL, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
+#define cfs_critical(...) cfs_log(CFS_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
#define cfs_dom_critical(domain, ...) cfs_log(domain, G_LOG_LEVEL_CRITICAL, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
-#define cfs_message(...) cfs_log(CFS_LOG_UNKNOWN, G_LOG_LEVEL_MESSAGE, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
+#define cfs_message(...) cfs_log(CFS_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
#define cfs_dom_message(domain, ...) cfs_log(domain, G_LOG_LEVEL_MESSAGE, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
guint64
diff --git a/data/src/cfs-plug-func.c b/data/src/cfs-plug-func.c
index 8447923..f589a40 100644
--- a/data/src/cfs-plug-func.c
+++ b/data/src/cfs-plug-func.c
@@ -34,6 +34,8 @@
#include <errno.h>
#include <dirent.h>
+#define CFS_LOG_DOMAIN CFS_LOG_MAIN
+
#include "cfs-utils.h"
#include "cfs-plug.h"
diff --git a/data/src/cfs-plug-link.c b/data/src/cfs-plug-link.c
index 58d442d..39b4dbb 100644
--- a/data/src/cfs-plug-link.c
+++ b/data/src/cfs-plug-link.c
@@ -34,6 +34,8 @@
#include <errno.h>
#include <dirent.h>
+#define CFS_LOG_DOMAIN CFS_LOG_MAIN
+
#include "cfs-utils.h"
#include "cfs-plug.h"
#include "status.h"
diff --git a/data/src/cfs-plug-memdb.c b/data/src/cfs-plug-memdb.c
index 901de7c..d9387a7 100644
--- a/data/src/cfs-plug-memdb.c
+++ b/data/src/cfs-plug-memdb.c
@@ -35,6 +35,8 @@
#include <dirent.h>
#include <arpa/inet.h>
+#define CFS_LOG_DOMAIN CFS_LOG_MAIN
+
#include "cfs-utils.h"
#include "cfs-plug-memdb.h"
#include "dcdb.h"
diff --git a/data/src/cfs-plug.c b/data/src/cfs-plug.c
index 108ed6b..9e0d105 100644
--- a/data/src/cfs-plug.c
+++ b/data/src/cfs-plug.c
@@ -34,6 +34,8 @@
#include <errno.h>
#include <dirent.h>
+#define CFS_LOG_DOMAIN CFS_LOG_MAIN
+
#include "cfs-utils.h"
#include "cfs-plug.h"
diff --git a/data/src/cfs-utils.c b/data/src/cfs-utils.c
index 134c1cb..9d1905f 100644
--- a/data/src/cfs-utils.c
+++ b/data/src/cfs-utils.c
@@ -241,36 +241,36 @@ atomic_write_file(
char *tmp_name = g_strdup_printf ("%s.XXXXXX", filename);
int fd = mkstemp(tmp_name);
if (fd == -1) {
- cfs_critical("Failed to create file '%s': %s", tmp_name, g_strerror(errno));
+ cfs_dom_critical(CFS_LOG_MAIN, "Failed to create file '%s': %s", tmp_name, g_strerror(errno));
res = FALSE;
goto ret;
}
if (fchown(fd, 0, gid) == -1) {
- cfs_critical("Failed to change group of file '%s': %s", tmp_name, g_strerror(errno));
+ cfs_dom_critical(CFS_LOG_MAIN, "Failed to change group of file '%s': %s", tmp_name, g_strerror(errno));
close(fd);
goto fail;
}
if (fchmod(fd, mode) == -1) {
- cfs_critical("Failed to change mode of file '%s': %s", tmp_name, g_strerror(errno));
+ cfs_dom_critical(CFS_LOG_MAIN, "Failed to change mode of file '%s': %s", tmp_name, g_strerror(errno));
close(fd);
goto fail;
}
if (len && !full_write(fd, data, len)) {
- cfs_critical("Failed to write file '%s': %s", tmp_name, g_strerror(errno));
+ cfs_dom_critical(CFS_LOG_MAIN, "Failed to write file '%s': %s", tmp_name, g_strerror(errno));
close(fd);
goto fail;
}
if (close(fd) == -1) {
- cfs_critical("Failed to close file '%s': %s", tmp_name, g_strerror(errno));
+ cfs_dom_critical(CFS_LOG_MAIN, "Failed to close file '%s': %s", tmp_name, g_strerror(errno));
goto fail;
}
if (rename(tmp_name, filename) == -1) {
- cfs_critical("Failed to rename file from '%s' to '%s': %s",
+ cfs_dom_critical(CFS_LOG_MAIN, "Failed to rename file from '%s' to '%s': %s",
tmp_name, filename, g_strerror(errno));
goto fail;
}
diff --git a/data/src/confdb.c b/data/src/confdb.c
index 7c4c992..c6aa72e 100644
--- a/data/src/confdb.c
+++ b/data/src/confdb.c
@@ -22,6 +22,7 @@
/* see "man cmap_overview" and "man cmap_keys" */
#define G_LOG_DOMAIN "confdb"
+#define CFS_LOG_DOMAIN CFS_LOG_CONFDB
#define CLUSTER_KEY "cluster"
diff --git a/data/src/database.c b/data/src/database.c
index 8ce8852..dd1b563 100644
--- a/data/src/database.c
+++ b/data/src/database.c
@@ -19,6 +19,7 @@
*/
#define G_LOG_DOMAIN "database"
+#define CFS_LOG_DOMAIN CFS_LOG_DB
#ifdef HAVE_CONFIG_H
#include <config.h>
diff --git a/data/src/dcdb.c b/data/src/dcdb.c
index b4f4359..4d32f9a 100644
--- a/data/src/dcdb.c
+++ b/data/src/dcdb.c
@@ -19,6 +19,7 @@
*/
#define G_LOG_DOMAIN "dcdb"
+#define CFS_LOG_DOMAIN CFS_LOG_DCDB
#ifdef HAVE_CONFIG_H
#include <config.h>
diff --git a/data/src/dfsm.c b/data/src/dfsm.c
index ab761e1..ab7a9bc 100644
--- a/data/src/dfsm.c
+++ b/data/src/dfsm.c
@@ -520,7 +520,7 @@ dfsm_set_mode(
{
g_return_if_fail(dfsm != NULL);
- cfs_debug("dfsm_set_mode - set mode to %d", new_mode);
+ cfs_dom_debug(dfsm->log_domain, "dfsm_set_mode - set mode to %d", new_mode);
int changed = 0;
g_mutex_lock (&dfsm->mode_mutex);
@@ -592,7 +592,7 @@ dfsm_release_sync_resources(
g_return_if_fail(dfsm->members != NULL);
g_return_if_fail(!member_list_entries || member_list != NULL);
- cfs_debug("enter dfsm_release_sync_resources");
+ cfs_dom_debug(dfsm->log_domain, "enter dfsm_release_sync_resources");
if (dfsm->sync_info) {
@@ -653,7 +653,9 @@ dfsm_cpg_deliver_callback(
dfsm_t *dfsm = NULL;
result = cpg_context_get(handle, (gpointer *)&dfsm);
if (result != CS_OK || !dfsm || dfsm->cpg_callbacks != &cpg_callbacks) {
- cfs_critical("cpg_context_get error: %d (%p)", result, (void *) dfsm);
+ cfs_dom_critical(dfsm ? dfsm->log_domain : CFS_LOG_UNKNOWN,
+ "cpg_context_get error: %d (%p)",
+ result, (void *) dfsm);
return; /* we have no valid dfsm pointer, so we can just ignore this */
}
dfsm_mode_t mode = dfsm_get_mode(dfsm);
@@ -1111,7 +1113,9 @@ dfsm_cpg_confchg_callback(
dfsm_t *dfsm = NULL;
result = cpg_context_get(handle, (gpointer *)&dfsm);
if (result != CS_OK || !dfsm || dfsm->cpg_callbacks != &cpg_callbacks) {
- cfs_critical("cpg_context_get error: %d (%p)", result, (void *) dfsm);
+ cfs_dom_critical(dfsm ? dfsm->log_domain : CFS_LOG_UNKNOWN,
+ "cpg_context_get error: %d (%p)",
+ result, (void *) dfsm);
return; /* we have no valid dfsm pointer, so we can just ignore this */
}
@@ -1323,7 +1327,7 @@ dfsm_verify_request(dfsm_t *dfsm)
iov[0].iov_base = (char *)&dfsm->csum_counter;
iov[0].iov_len = sizeof(dfsm->csum_counter);
- cfs_debug("send verify request %016" PRIX64, dfsm->csum_counter);
+ cfs_dom_debug(dfsm->log_domain, "send verify request %016" PRIX64, dfsm->csum_counter);
cs_error_t result;
result = dfsm_send_state_message_full(dfsm, DFSM_MESSAGE_VERIFY_REQUEST, iov, len);
diff --git a/data/src/logger.c b/data/src/logger.c
index 4cf9cce..47a789b 100644
--- a/data/src/logger.c
+++ b/data/src/logger.c
@@ -39,6 +39,8 @@
#define SYSLOG_MAX_LINE_LENGTH 8192
+#define CFS_LOG_DOMAIN CFS_LOG_MAIN
+
#include "cfs-utils.h"
#include "logger.h"
diff --git a/data/src/loop.c b/data/src/loop.c
index 09c8590..59bb7be 100644
--- a/data/src/loop.c
+++ b/data/src/loop.c
@@ -19,6 +19,7 @@
*/
#define G_LOG_DOMAIN "loop"
+#define CFS_LOG_DOMAIN CFS_LOG_LOOP
#ifdef HAVE_CONFIG_H
#include <config.h>
diff --git a/data/src/memdb.c b/data/src/memdb.c
index 33ea44d..2cf09b5 100644
--- a/data/src/memdb.c
+++ b/data/src/memdb.c
@@ -35,6 +35,8 @@
#include <errno.h>
#include <glib.h>
+#define CFS_LOG_DOMAIN CFS_LOG_MAIN
+
#include "cfs-utils.h"
#include "memdb.h"
#include "status.h"
diff --git a/data/src/pmxcfs.c b/data/src/pmxcfs.c
index d5a3aac..00aa53d 100644
--- a/data/src/pmxcfs.c
+++ b/data/src/pmxcfs.c
@@ -46,6 +46,8 @@
#include <qb/qbutil.h>
#include <qb/qblog.h>
+#define CFS_LOG_DOMAIN CFS_LOG_MAIN
+
#include "cfs-utils.h"
#include "cfs-plug.h"
#include "cfs-plug-memdb.h"
diff --git a/data/src/quorum.c b/data/src/quorum.c
index 0a75f7f..41126a0 100644
--- a/data/src/quorum.c
+++ b/data/src/quorum.c
@@ -19,6 +19,7 @@
*/
#define G_LOG_DOMAIN "quorum"
+#define CFS_LOG_DOMAIN CFS_LOG_QUORUM
#ifdef HAVE_CONFIG_H
#include <config.h>
diff --git a/data/src/server.c b/data/src/server.c
index 549788a..214d6a9 100644
--- a/data/src/server.c
+++ b/data/src/server.c
@@ -19,6 +19,7 @@
*/
#define G_LOG_DOMAIN "ipcs"
+#define CFS_LOG_DOMAIN CFS_LOG_IPCS
#ifdef HAVE_CONFIG_H
#include <config.h>
diff --git a/data/src/status.c b/data/src/status.c
index 004f02e..43d6763 100644
--- a/data/src/status.c
+++ b/data/src/status.c
@@ -19,6 +19,7 @@
*/
#define G_LOG_DOMAIN "status"
+#define CFS_LOG_DOMAIN CFS_LOG_STATUS
#ifdef HAVE_CONFIG_H
#include <config.h>
--
2.20.1
More information about the pve-devel
mailing list