summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-log-ops.c
diff options
context:
space:
mode:
authorNandaja Varma <nandaja.varma@gmail.com>2015-03-17 13:16:06 +0530
committerAtin Mukherjee <amukherj@redhat.com>2015-06-20 21:27:06 -0700
commit38d602e820b99b0c9e2efe788df7450e4d863196 (patch)
tree81d2d62adaae3e55662fe11c9772b9944f54a7aa /xlators/mgmt/glusterd/src/glusterd-log-ops.c
parent16115c232e48f080624b68eb94f813fb3c226e58 (diff)
ops/glusterd: Porting messages to new logging framework
cherry-picked from commit 70bb8bf65b4cefb503fa94452c200b0b71a06535 >Change-Id: Iafeb07aabc1781d98f51c6c2627bf3bbdf493153 >BUG: 1194640 >Signed-off-by: Nandaja Varma <nandaja.varma@gmail.com> >Reviewed-on: http://review.gluster.org/9905 >Tested-by: Gluster Build System <jenkins@build.gluster.com> >Tested-by: NetBSD Build System <jenkins@build.gluster.org> >Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Change-Id: Iafeb07aabc1781d98f51c6c2627bf3bbdf493153 BUG: 1217722 Signed-off-by: Nandaja Varma <nvarma@redhat.com> Reviewed-on: http://review.gluster.org/11230 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-log-ops.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-log-ops.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
index 449b28cdbf1..76116377496 100644
--- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
@@ -20,6 +20,7 @@
#include "glusterd-store.h"
#include "glusterd-utils.h"
#include "glusterd-volgen.h"
+#include "glusterd-messages.h"
#include <signal.h>
@@ -53,7 +54,8 @@ __glusterd_handle_log_rotate (rpcsvc_request_t *req)
cli_req.dict.dict_len,
&dict);
if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR,
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_UNSERIALIZE_FAIL,
"failed to "
"unserialize req-buffer to dictionary");
snprintf (msg, sizeof (msg), "Unable to decode the "
@@ -65,7 +67,8 @@ __glusterd_handle_log_rotate (rpcsvc_request_t *req)
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
snprintf (msg, sizeof (msg), "Failed to get volume name");
- gf_log (this->name, GF_LOG_ERROR, "%s", msg);
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "%s", msg);
goto out;
}
@@ -110,7 +113,8 @@ glusterd_op_stage_log_rotate (dict_t *dict, char **op_errstr)
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to get volume name");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "Unable to get volume name");
goto out;
}
@@ -119,7 +123,8 @@ glusterd_op_stage_log_rotate (dict_t *dict, char **op_errstr)
if (!exists) {
snprintf (msg, sizeof (msg), "Volume %s does not exist",
volname);
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_FOUND, "%s", msg);
*op_errstr = gf_strdup (msg);
ret = -1;
goto out;
@@ -128,7 +133,8 @@ glusterd_op_stage_log_rotate (dict_t *dict, char **op_errstr)
if (_gf_false == glusterd_is_volume_started (volinfo)) {
snprintf (msg, sizeof (msg), "Volume %s needs to be started before"
" log rotate.", volname);
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_VOL_NOT_STARTED, "%s", msg);
*op_errstr = gf_strdup (msg);
ret = -1;
goto out;
@@ -146,12 +152,13 @@ glusterd_op_stage_log_rotate (dict_t *dict, char **op_errstr)
if (ret) {
snprintf (msg, sizeof (msg), "Incorrect brick %s "
"for volume %s", brick, volname);
- gf_log ("", GF_LOG_ERROR, "%s", msg);
+ gf_msg ("glusterd", GF_LOG_ERROR, EINVAL,
+ GD_MSG_INVALID_ENTRY, "%s", msg);
*op_errstr = gf_strdup (msg);
goto out;
}
out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -182,13 +189,15 @@ glusterd_op_log_rotate (dict_t *dict)
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "volname not found");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "volname not found");
goto out;
}
ret = dict_get_uint64 (dict, "rotate-key", &key);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "rotate key not found");
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_DICT_GET_FAILED, "rotate key not found");
goto out;
}
@@ -200,7 +209,8 @@ glusterd_op_log_rotate (dict_t *dict)
ret = glusterd_brickinfo_new_from_brick (brick, &tmpbrkinfo);
if (ret) {
- gf_log ("glusterd", GF_LOG_ERROR,
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_NOT_FOUND,
"cannot get brickinfo from brick");
goto out;
}
@@ -225,7 +235,8 @@ cont:
GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv);
file = fopen (pidfile, "r+");
if (!file) {
- gf_log ("", GF_LOG_ERROR, "Unable to open pidfile: %s",
+ gf_msg ("glusterd", GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "Unable to open pidfile: %s",
pidfile);
ret = -1;
goto out;
@@ -233,7 +244,8 @@ cont:
ret = fscanf (file, "%d", &pid);
if (ret <= 0) {
- gf_log ("", GF_LOG_ERROR, "Unable to read pidfile: %s",
+ gf_msg ("glusterd", GF_LOG_ERROR, errno,
+ GD_MSG_FILE_OP_FAILED, "Unable to read pidfile: %s",
pidfile);
ret = -1;
goto out;
@@ -246,11 +258,13 @@ cont:
ret = rename (brickinfo->logfile, logfile);
if (ret)
- gf_log ("", GF_LOG_WARNING, "rename failed");
+ gf_msg ("glusterd", GF_LOG_WARNING, errno,
+ GD_MSG_FILE_OP_FAILED, "rename failed");
ret = kill (pid, SIGHUP);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to SIGHUP to %d", pid);
+ gf_msg ("glusterd", GF_LOG_ERROR, errno,
+ GD_MSG_PID_KILL_FAIL, "Unable to SIGHUP to %d", pid);
goto out;
}
ret = 0;