From 8708953fa3d9187997dc6d484dae663b4469c7ca Mon Sep 17 00:00:00 2001 From: Nandaja Varma Date: Thu, 25 Jun 2015 00:57:00 +0530 Subject: glusterd: Porting left out log messages to new framework This is a backport of http://review.gluster.org/11388 cherry-picked from commit 23c1e6dc0fa86c014e1a8b6aa5729675f6d69017 >Change-Id: I70d40ae3b5f49a21e1b93f82885cd58fa2723647 >BUG: 1235538 >Signed-off-by: Nandaja Varma Change-Id: I70d40ae3b5f49a21e1b93f82885cd58fa2723647 BUG: 1217722 Signed-off-by: Nandaja Varma Reviewed-on: http://review.gluster.org/11422 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Anand Nekkunti Reviewed-by: Kaushal M --- xlators/mgmt/glusterd/src/glusterd-hooks.c | 50 ++++++++++++++++++------------ 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-hooks.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-hooks.c b/xlators/mgmt/glusterd/src/glusterd-hooks.c index 3e3f18959b0..220c6b022f5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-hooks.c +++ b/xlators/mgmt/glusterd/src/glusterd-hooks.c @@ -28,6 +28,7 @@ #include "glusterd-utils.h" #include "glusterd-store.h" #include "glusterd-hooks.h" +#include "glusterd-messages.h" #include @@ -89,16 +90,18 @@ glusterd_hooks_create_hooks_directory (char *basedir) snprintf (path, sizeof (path), "%s/hooks", basedir); ret = mkdir_p (path, 0777, _gf_true); if (ret) { - gf_log (THIS->name, GF_LOG_CRITICAL, "Unable to create %s due" - "to %s", path, strerror (errno)); + gf_msg (THIS->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create %s", + path); goto out; } GLUSTERD_GET_HOOKS_DIR (version_dir, GLUSTERD_HOOK_VER, priv); ret = mkdir_p (version_dir, 0777, _gf_true); if (ret) { - gf_log (THIS->name, GF_LOG_CRITICAL, "Unable to create %s due " - "to %s", version_dir, strerror (errno)); + gf_msg (THIS->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, "Unable to create %s", + version_dir); goto out; } @@ -111,9 +114,10 @@ glusterd_hooks_create_hooks_directory (char *basedir) cmd_subdir); ret = mkdir_p (path, 0777, _gf_true); if (ret) { - gf_log (THIS->name, GF_LOG_CRITICAL, - "Unable to create %s due to %s", - path, strerror (errno)); + gf_msg (THIS->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, + "Unable to create %s", + path); goto out; } @@ -123,9 +127,10 @@ glusterd_hooks_create_hooks_directory (char *basedir) version_dir, cmd_subdir, type_subdir[type]); ret = mkdir_p (path, 0777, _gf_true); if (ret) { - gf_log (THIS->name, GF_LOG_CRITICAL, - "Unable to create %s due to %s", - path, strerror (errno)); + gf_msg (THIS->name, GF_LOG_CRITICAL, errno, + GD_MSG_CREATE_DIR_FAILED, + "Unable to create %s", + path); goto out; } } @@ -176,10 +181,10 @@ glusterd_hooks_add_custom_args (dict_t *dict, runner_t *runner) ret = dict_get_str (dict, "hooks_args", &hooks_args); if (ret) - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "No Hooks Arguments."); else - gf_log (this->name, GF_LOG_DEBUG, + gf_msg_debug (this->name, 0, "Hooks Args = %s", hooks_args); if (hooks_args) @@ -337,7 +342,8 @@ glusterd_hooks_run_hooks (char *hooks_path, glusterd_op_t op, dict_t *op_ctx, ret = dict_get_str (op_ctx, "volname", &volname); if (ret) { - gf_log (this->name, GF_LOG_CRITICAL, "Failed to get volname " + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_DICT_GET_FAILED, "Failed to get volname " "from operation context"); goto out; } @@ -345,8 +351,10 @@ glusterd_hooks_run_hooks (char *hooks_path, glusterd_op_t op, dict_t *op_ctx, hookdir = opendir (hooks_path); if (!hookdir) { ret = -1; - gf_log (this->name, GF_LOG_ERROR, "Failed to open dir %s, due " - "to %s", hooks_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + GD_MSG_DIR_OP_FAILED, + "Failed to open dir %s", + hooks_path); goto out; } @@ -390,7 +398,8 @@ glusterd_hooks_run_hooks (char *hooks_path, glusterd_op_t op, dict_t *op_ctx, runner_argprintf (&runner, "--volname=%s", volname); ret = glusterd_hooks_add_op_args (&runner, op, op_ctx, type); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Failed to add " + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_ADD_OP_ARGS_FAIL, "Failed to add " "command specific arguments"); goto out; } @@ -480,7 +489,8 @@ glusterd_hooks_stub_init (glusterd_hooks_stub_t **stub, char *scriptdir, ret = 0; out: if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, "Failed to initialize " + gf_msg (THIS->name, GF_LOG_ERROR, 0, + GD_MSG_POST_HOOK_STUB_INIT_FAIL, "Failed to initialize " "post hooks stub"); glusterd_hooks_stub_cleanup (hooks_stub); } @@ -492,7 +502,8 @@ void glusterd_hooks_stub_cleanup (glusterd_hooks_stub_t *stub) { if (!stub) { - gf_log_callingfn (THIS->name, GF_LOG_WARNING, + gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0, + GD_MSG_HOOK_STUB_NULL, "hooks_stub is NULL"); return; } @@ -582,7 +593,8 @@ glusterd_hooks_spawn_worker (xlator_t *this) ret = pthread_create (&hooks_priv->worker, NULL, hooks_worker, (void *)this); if (ret) - gf_log (this->name, GF_LOG_CRITICAL, "Failed to spawn post " + gf_msg (this->name, GF_LOG_CRITICAL, errno, + GD_MSG_SPAWN_THREADS_FAIL, "Failed to spawn post " "hooks worker thread"); out: return ret; -- cgit