Blob Blame History Raw
From dab6b91c987cd2cfcd0c26114780cee5845190d4 Mon Sep 17 00:00:00 2001
From: Nandaja Varma <nandaja.varma@gmail.com>
Date: Fri, 13 Mar 2015 16:55:17 +0530
Subject: [PATCH 088/101] rebalance,store,glusterd/glusterd: porting to new logging framework

cherry-picked from commit 25f28a9c23b1adf665a982c2f5157bf13361521b
>Change-Id: I231b79e3414e60fe67cde577dd585cce83c8bfad
>BUG: 1194640
>Signed-off-by: Nandaja Varma <nandaja.varma@gmail.com>
>Reviewed-on: http://review.gluster.org/9877
>Tested-by: Gluster Build System <jenkins@build.gluster.com>
>Reviewed-by: Sachin Pandit <spandit@redhat.com>
>Tested-by: NetBSD Build System <jenkins@build.gluster.org>
>Reviewed-by: Atin Mukherjee <amukherj@redhat.com>

Change-Id: I231b79e3414e60fe67cde577dd585cce83c8bfad
BUG: 1231771
Signed-off-by: Nandaja Varma <nvarma@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/50895
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/mgmt/glusterd/src/glusterd-rebalance.c |  102 +++--
 xlators/mgmt/glusterd/src/glusterd-store.c     |  552 +++++++++++++++---------
 xlators/mgmt/glusterd/src/glusterd.c           |  208 ++++++---
 3 files changed, 538 insertions(+), 324 deletions(-)

diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index 0367df3..4fd95c2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -55,7 +55,7 @@ glusterd_defrag_start_validate (glusterd_volinfo_t *volinfo, char *op_errstr,
         /* Check only if operation is not remove-brick */
         if ((GD_OP_REMOVE_BRICK != op) &&
             !gd_is_remove_brick_committed (volinfo)) {
-                gf_log (this->name, GF_LOG_DEBUG, "A remove-brick task on "
+                gf_msg_debug (this->name, 0, "A remove-brick task on "
                         "volume %s is not yet committed", volinfo->volname);
                 snprintf (op_errstr, len, "A remove-brick task on volume %s is"
                           " not yet committed. Either commit or stop the "
@@ -64,7 +64,7 @@ glusterd_defrag_start_validate (glusterd_volinfo_t *volinfo, char *op_errstr,
         }
 
         if (glusterd_is_defrag_on (volinfo)) {
-                gf_log (this->name, GF_LOG_DEBUG,
+                gf_msg_debug (this->name, 0,
                         "rebalance on volume %s already started",
                         volinfo->volname);
                 snprintf (op_errstr, len, "Rebalance on %s is already started",
@@ -74,7 +74,7 @@ glusterd_defrag_start_validate (glusterd_volinfo_t *volinfo, char *op_errstr,
 
         ret = 0;
 out:
-        gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (this->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -123,7 +123,7 @@ __glusterd_defrag_notify (struct rpc_clnt *rpc, void *mydata,
                 }
                 UNLOCK (&defrag->lock);
 
-               gf_log ("", GF_LOG_DEBUG, "%s got RPC_CLNT_CONNECT",
+               gf_msg_debug (this->name, 0, "%s got RPC_CLNT_CONNECT",
                         rpc->conn.name);
                break;
         }
@@ -165,7 +165,7 @@ __glusterd_defrag_notify (struct rpc_clnt *rpc, void *mydata,
                 glusterd_volinfo_unref (volinfo);
                 break;
         default:
-                gf_log ("", GF_LOG_TRACE,
+                gf_msg_trace (this->name, 0,
                         "got some other RPC event %d", event);
                 ret = 0;
                 break;
@@ -234,7 +234,8 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr,
         GLUSTERD_GET_DEFRAG_DIR (defrag_path, volinfo, priv);
         ret = mkdir_p (defrag_path, 0777, _gf_true);
         if (ret) {
-                gf_log (THIS->name, GF_LOG_ERROR, "Failed to create "
+                gf_msg (THIS->name, GF_LOG_ERROR, errno,
+                        GD_MSG_CREATE_DIR_FAILED, "Failed to create "
                         "directory %s", defrag_path);
                 goto out;
         }
@@ -296,7 +297,7 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr,
 
         ret = runner_run_nowait (&runner);
         if (ret) {
-                gf_log ("glusterd", GF_LOG_DEBUG, "rebalance command failed");
+                gf_msg_debug ("glusterd", 0, "rebalance command failed");
                 goto out;
         }
 
@@ -310,7 +311,7 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr,
                 defrag->cbk_fn = cbk;
 
 out:
-        gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug ("glusterd", 0, "Returning %d", ret);
         return ret;
 }
 
@@ -352,7 +353,8 @@ glusterd_rebalance_rpc_create (glusterd_volinfo_t *volinfo,
                  * with the older path
                  */
                 if (ret && (errno == ENOENT)) {
-                        gf_log (this->name, GF_LOG_WARNING, "Rebalance sockfile "
+                        gf_msg (this->name, GF_LOG_WARNING, errno,
+                                GD_MSG_FILE_OP_FAILED, "Rebalance sockfile "
                                 "%s does not exist. Trying old path.",
                                 sockfile);
                         GLUSTERD_GET_DEFRAG_SOCK_FILE_OLD (sockfile, volinfo,
@@ -400,14 +402,16 @@ glusterd_rebalance_cmd_validate (int cmd, char *volname,
         int ret = -1;
 
         if (glusterd_volinfo_find(volname, volinfo)) {
-                gf_log ("glusterd", GF_LOG_ERROR, "Received rebalance on invalid"
+                gf_msg ("glusterd", GF_LOG_ERROR, EINVAL,
+                        GD_MSG_VOL_NOT_FOUND, "Received rebalance on invalid"
                         " volname %s", volname);
                 snprintf (op_errstr, len, "Volume %s does not exist",
                           volname);
                 goto out;
         }
         if ((*volinfo)->brick_count <= (*volinfo)->dist_leaf_count) {
-                gf_log ("glusterd", GF_LOG_ERROR, "Volume %s is not a "
+                gf_msg ("glusterd", GF_LOG_ERROR, 0,
+                        GD_MSG_VOL_NOT_DISTRIBUTE, "Volume %s is not a "
                 "distribute type or contains only 1 brick", volname);
                 snprintf (op_errstr, len, "Volume %s is not a distribute "
                           "volume or contains only 1 brick.\n"
@@ -416,7 +420,8 @@ glusterd_rebalance_cmd_validate (int cmd, char *volname,
         }
 
         if ((*volinfo)->status != GLUSTERD_STATUS_STARTED) {
-                gf_log ("glusterd", GF_LOG_ERROR, "Received rebalance on stopped"
+                gf_msg ("glusterd", GF_LOG_ERROR, 0,
+                        GD_MSG_VOL_STOPPED, "Received rebalance on stopped"
                         " volname %s", volname);
                 snprintf (op_errstr, len, "Volume %s needs to "
                           "be started to perform rebalance", volname);
@@ -435,7 +440,7 @@ glusterd_rebalance_cmd_validate (int cmd, char *volname,
         ret = 0;
 
 out:
-        gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug ("glusterd", 0, "Returning %d", ret);
         return ret;
 }
 
@@ -473,7 +478,8 @@ __glusterd_handle_defrag_volume (rpcsvc_request_t *req)
                                         cli_req.dict.dict_len,
                                         &dict);
                 if (ret < 0) {
-                        gf_log (this->name, GF_LOG_ERROR, "failed to "
+                        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 "
                                   "command");
@@ -484,14 +490,16 @@ __glusterd_handle_defrag_volume (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;
         }
 
         ret = dict_get_int32 (dict, "rebalance-command", (int32_t*)&cmd);
         if (ret) {
                 snprintf (msg, sizeof (msg), "Failed to get command");
-                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;
         }
 
@@ -581,20 +589,20 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
 
         ret = dict_get_str (dict, "volname", &volname);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG, "volname not found");
+                gf_msg_debug (this->name, 0, "volname not found");
                 goto out;
         }
 
         ret = dict_get_int32 (dict, "rebalance-command", &cmd);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG, "cmd not found");
+                gf_msg_debug (this->name, 0, "cmd not found");
                 goto out;
         }
 
         ret = glusterd_rebalance_cmd_validate (cmd, volname, &volinfo,
                                                msg, sizeof (msg));
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG, "failed to validate");
+                gf_msg_debug (this->name, 0, "failed to validate");
                 goto out;
         }
         switch (cmd) {
@@ -626,7 +634,8 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
                         op_ctx = glusterd_op_get_ctx ();
                         if (!op_ctx) {
                                 ret = -1;
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_OPCTX_GET_FAIL,
                                         "Failed to get op_ctx");
                                 goto out;
                         }
@@ -634,7 +643,8 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
                         ret = glusterd_generate_and_set_task_id
                                 (op_ctx, GF_REBALANCE_TID_KEY);
                         if (ret) {
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_TASKID_GEN_FAIL,
                                         "Failed to generate task-id");
                                 goto out;
                         }
@@ -644,7 +654,8 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
                         if (ret) {
                                 snprintf (msg, sizeof (msg),
                                           "Missing rebalance-id");
-                                gf_log (this->name, GF_LOG_WARNING, "%s", msg);
+                                gf_msg (this->name, GF_LOG_WARNING, 0,
+                                        GD_MSG_REBALANCE_ID_MISSING, "%s", msg);
                                 ret = 0;
                         }
                 }
@@ -652,7 +663,7 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
                                                       sizeof (msg),
                                                       GD_OP_REBALANCE);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_DEBUG,
+                        gf_msg_debug (this->name, 0,
                                         "start validate failed");
                         goto out;
                 }
@@ -662,10 +673,11 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
         case GF_DEFRAG_CMD_STOP_DETACH_TIER:
                 ret = dict_get_str (dict, "cmd-str", &cmd_str);
                 if (ret) {
-                     gf_log (this->name, GF_LOG_ERROR, "Failed to get "
-                             "command string");
-                     ret = -1;
-                     goto out;
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_DICT_GET_FAILED, "Failed to get "
+                                "command string");
+                        ret = -1;
+                        goto out;
                 }
                 if ((strstr(cmd_str, "rebalance") != NULL) &&
                     (volinfo->rebal.op != GD_OP_REBALANCE)) {
@@ -736,13 +748,13 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
 
         ret = dict_get_str (dict, "volname", &volname);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG, "volname not given");
+                gf_msg_debug (this->name, 0, "volname not given");
                 goto out;
         }
 
         ret = dict_get_int32 (dict, "rebalance-command", &cmd);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG, "command not given");
+                gf_msg_debug (this->name, 0, "command not given");
                 goto out;
         }
 
@@ -750,7 +762,7 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
         ret = glusterd_rebalance_cmd_validate (cmd, volname, &volinfo,
                                                msg, sizeof (msg));
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG, "cmd validate failed");
+                gf_msg_debug (this->name, 0, "cmd validate failed");
                 goto out;
         }
 
@@ -763,7 +775,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
                 if (!gf_uuid_is_null (volinfo->rebal.rebalance_id)) {
                         ctx = glusterd_op_get_ctx ();
                         if (!ctx) {
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_OPCTX_GET_FAIL,
                                         "Failed to get op_ctx");
                                 ret = -1;
                                 goto out;
@@ -778,7 +791,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
                                         (volinfo->rebal.rebalance_id, ctx,
                                          GF_REBALANCE_TID_KEY);
                         if (ret) {
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_TASKID_GEN_FAIL,
                                         "Failed to set task-id");
                                 goto out;
                         }
@@ -798,7 +812,7 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
 
                 ret = dict_get_str (dict, GF_REBALANCE_TID_KEY, &task_id_str);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_DEBUG, "Missing rebalance "
+                        gf_msg_debug (this->name, 0, "Missing rebalance "
                                 "id");
                         ret = 0;
                 } else {
@@ -848,7 +862,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
 
                 ret = glusterd_create_volfiles_and_notify_services (volinfo);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_WARNING,
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
+                                GD_MSG_VOLFILE_CREATE_FAIL,
                                 "failed to create volfiles");
                         goto out;
                 }
@@ -856,7 +871,8 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
                 ret = glusterd_store_volinfo (volinfo,
                                              GLUSTERD_VOLINFO_VER_AC_INCREMENT);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_WARNING,
+                        gf_msg (this->name, GF_LOG_WARNING, 0,
+                                GD_MSG_VOLINFO_SET_FAIL,
                                 "failed to store volinfo");
                         goto out;
                 }
@@ -894,7 +910,8 @@ glusterd_defrag_event_notify_handle (dict_t *dict)
 
         ret = dict_get_str (dict, "volname", &volname);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to get volname");
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_DICT_GET_FAILED, "Failed to get volname");
                 return ret;
         }
 
@@ -907,8 +924,9 @@ glusterd_defrag_event_notify_handle (dict_t *dict)
                 }
                 volname = volname_ptr + 1;
         } else {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "volname received (%s) is not prefixed with rebalance.",
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_NO_REBALANCE_PFX_IN_VOLNAME,
+                        "volname recieved (%s) is not prefixed with rebalance.",
                         volname);
                 ret = -1;
                 goto out;
@@ -916,7 +934,9 @@ glusterd_defrag_event_notify_handle (dict_t *dict)
 
         ret = glusterd_volinfo_find (volname, &volinfo);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to get volinfo for %s"
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_VOLINFO_GET_FAIL,
+                        "Failed to get volinfo for %s"
                         , volname);
                 return ret;
         }
@@ -924,7 +944,9 @@ glusterd_defrag_event_notify_handle (dict_t *dict)
         ret = glusterd_defrag_volume_status_update (volinfo, dict);
 
         if (ret)
-                gf_log (this->name, GF_LOG_ERROR, "Failed to update status");
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_DEFRAG_STATUS_UPDATE_FAIL,
+                        "Failed to update status");
 
 out:
         return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index ae87e9a..d790c6f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -38,6 +38,7 @@
 #include "store.h"
 #include "glusterd-store.h"
 #include "glusterd-snapshot-utils.h"
+#include "glusterd-messages.h"
 
 #include "rpc-clnt.h"
 #include "common-utils.h"
@@ -170,19 +171,22 @@ glusterd_store_is_valid_brickpath (char *volname, char *brick)
 
         ret = glusterd_brickinfo_new_from_brick (brick, &brickinfo);
         if (ret) {
-                gf_log (this->name, GF_LOG_WARNING, "Failed to create brick "
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        GD_MSG_BRICK_CREATION_FAIL, "Failed to create brick "
                         "info for brick %s", brick);
                 ret = 0;
                 goto out;
         }
         ret = glusterd_volinfo_new (&volinfo);
         if (ret) {
-                gf_log (this->name, GF_LOG_WARNING, "Failed to create volinfo");
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        GD_MSG_VOLFILE_CREATE_FAIL, "Failed to create volinfo");
                 ret = 0;
                 goto out;
         }
         if (volname_len >= sizeof (volinfo->volname)) {
-                gf_log (this->name, GF_LOG_WARNING, "volume name too long");
+                gf_msg (this->name, GF_LOG_WARNING, 0,
+                        GD_MSG_NAME_TOO_LONG, "volume name too long");
                 ret = 0;
                 goto out;
         }
@@ -332,7 +336,8 @@ gd_store_brick_snap_details_write (int fd, glusterd_brickinfo_t *brickinfo)
                 ret = gf_store_save_value (fd,
                                 GLUSTERD_STORE_KEY_BRICK_FSTYPE, value);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR, "Failed to save "
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_FS_LABEL_UPDATE_FAIL, "Failed to save "
                                 "brick fs type of brick %s", brickinfo->path);
                         goto out;
                 }
@@ -343,7 +348,8 @@ gd_store_brick_snap_details_write (int fd, glusterd_brickinfo_t *brickinfo)
                 ret = gf_store_save_value (fd,
                                 GLUSTERD_STORE_KEY_BRICK_MNTOPTS, value);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR, "Failed to save "
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_BRK_MOUNTOPTS_FAIL, "Failed to save "
                                 "brick mnt opts of brick %s", brickinfo->path);
                         goto out;
                 }
@@ -405,7 +411,7 @@ glusterd_store_brickinfo_write (int fd, glusterd_brickinfo_t *brickinfo)
         ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_BRICK_VGNAME,
                                          brickinfo->vg);
 out:
-        gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (THIS->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -425,11 +431,13 @@ glusterd_store_snapd_write (int fd, glusterd_volinfo_t *volinfo)
         snprintf (value, sizeof(value), "%d", volinfo->snapd.port);
         ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAPD_PORT, value);
         if (ret)
-                gf_log (this->name, GF_LOG_ERROR, "failed to store the snapd "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAPD_PORT_STORE_FAIL,
+                        "failed to store the snapd "
                         "port of volume %s", volinfo->volname);
 
 
-        gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (this->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -453,7 +461,7 @@ glusterd_store_perform_brick_store (glusterd_brickinfo_t *brickinfo)
 out:
         if (ret && (fd > 0))
                 gf_store_unlink_tmppath (brickinfo->shandle);
-        gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (THIS->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -471,7 +479,8 @@ glusterd_store_perform_snapd_store (glusterd_volinfo_t *volinfo)
 
         fd = gf_store_mkstemp (volinfo->snapd.handle);
         if (fd <= 0) {
-                gf_log (this->name, GF_LOG_ERROR, "failed to create the "
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_FILE_OP_FAILED, "failed to create the "
                         "temporary file for the snapd store handle of volume "
                         "%s", volinfo->volname);
                 goto out;
@@ -479,7 +488,9 @@ glusterd_store_perform_snapd_store (glusterd_volinfo_t *volinfo)
 
         ret = glusterd_store_snapd_write (fd, volinfo);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "failed to write snapd port "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAPD_PORT_STORE_FAIL,
+                        "failed to write snapd port "
                         "info to store handle (volume: %s", volinfo->volname);
                 goto out;
         }
@@ -489,7 +500,7 @@ glusterd_store_perform_snapd_store (glusterd_volinfo_t *volinfo)
 out:
         if (ret && (fd > 0))
                 gf_store_unlink_tmppath (volinfo->snapd.handle);
-        gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (THIS->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -519,7 +530,7 @@ glusterd_store_brickinfo (glusterd_volinfo_t *volinfo,
 
         ret = glusterd_store_perform_brick_store (brickinfo);
 out:
-        gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug (THIS->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -536,21 +547,25 @@ glusterd_store_snapd_info (glusterd_volinfo_t *volinfo)
 
         ret = glusterd_store_create_snapd_shandle_on_absence (volinfo);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "failed to create store "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_HANDLE_CREATE_FAIL,
+                        "failed to create store "
                         "handle for snapd (volume: %s)", volinfo->volname);
                 goto out;
         }
 
         ret = glusterd_store_perform_snapd_store (volinfo);
         if (ret)
-                gf_log (this->name, GF_LOG_ERROR, "failed to store snapd info "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAPD_INFO_STORE_FAIL,
+                        "failed to store snapd info "
                         "of the volume %s", volinfo->volname);
 
 out:
         if (ret)
                 gf_store_unlink_tmppath (volinfo->snapd.handle);
 
-        gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug (this->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -589,8 +604,8 @@ glusterd_store_delete_brick (glusterd_brickinfo_t *brickinfo, char *delete_path)
         ret = unlink (brickpath);
 
         if ((ret < 0) && (errno != ENOENT)) {
-                gf_log (this->name, GF_LOG_DEBUG, "Unlink failed on %s, "
-                        "reason: %s", brickpath, strerror(errno));
+                gf_msg_debug (this->name, 0, "Unlink failed on %s",
+                              brickpath);
                 ret = -1;
                 goto out;
         } else {
@@ -602,7 +617,7 @@ out:
                 gf_store_handle_destroy (brickinfo->shandle);
                 brickinfo->shandle = NULL;
         }
-        gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug (this->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -644,8 +659,8 @@ glusterd_store_remove_bricks (glusterd_volinfo_t *volinfo, char *delete_path)
                           brickdir, entry->d_name);
                 ret = unlink (path);
                 if (ret && errno != ENOENT) {
-                        gf_log (this->name, GF_LOG_DEBUG, "Unable to unlink %s, "
-                                "reason: %s", path, strerror(errno));
+                        gf_msg_debug (this->name, 0, "Unable to unlink %s",
+                                      path);
                 }
                 GF_FOR_EACH_ENTRY_IN_DIR (entry, dir);
         }
@@ -655,7 +670,7 @@ glusterd_store_remove_bricks (glusterd_volinfo_t *volinfo, char *delete_path)
         ret = rmdir (brickdir);
 
 out:
-        gf_log (this->name, GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug (this->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -685,13 +700,15 @@ _storeslaves (dict_t *this, char *key, data_t *value, void *data)
         if (!value || !value->data)
                 return -1;
 
-        gf_log (xl->name, GF_LOG_DEBUG, "Storing in volinfo:key= %s, val=%s",
+        gf_msg_debug (xl->name, 0, "Storing in volinfo:key= %s, val=%s",
                 key, value->data);
 
         ret = gf_store_save_value (shandle->fd, key, (char*)value->data);
         if (ret) {
-                gf_log (xl->name, GF_LOG_ERROR, "Unable to write into store"
-                                " handle for path: %s", shandle->path);
+                gf_msg (xl->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_HANDLE_WRITE_FAIL,
+                        "Unable to write into store"
+                        " handle for path: %s", shandle->path);
                 return -1;
         }
         return 0;
@@ -732,18 +749,20 @@ int _storeopts (dict_t *this, char *key, data_t *value, void *data)
         }
 
         if (1 == exists) {
-                gf_log (xl->name, GF_LOG_DEBUG, "Storing in volinfo:key= %s, "
+                gf_msg_debug (xl->name, 0, "Storing in volinfo:key= %s, "
                         "val=%s", key, value->data);
 
         } else {
-                gf_log (xl->name, GF_LOG_DEBUG, "Discarding:key= %s, val=%s",
+                gf_msg_debug (xl->name, 0, "Discarding:key= %s, val=%s",
                         key, value->data);
                 return 0;
         }
 
         ret = gf_store_save_value (shandle->fd, key, (char*)value->data);
         if (ret) {
-                gf_log (xl->name, GF_LOG_ERROR, "Unable to write into store"
+                gf_msg (xl->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_HANDLE_WRITE_FAIL,
+                        "Unable to write into store"
                         " handle for path: %s", shandle->path);
                 return -1;
         }
@@ -779,7 +798,8 @@ glusterd_volume_write_snap_details (int fd, glusterd_volinfo_t *volinfo)
         snprintf (buf, sizeof (buf), "%s", volinfo->parent_volname);
         ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_PARENT_VOLNAME, buf);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to store "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_FAIL, "Failed to store "
                         GLUSTERD_STORE_KEY_PARENT_VOLNAME);
                 goto out;
         }
@@ -787,7 +807,8 @@ glusterd_volume_write_snap_details (int fd, glusterd_volinfo_t *volinfo)
         ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_RESTORED_SNAP,
                                    uuid_utoa (volinfo->restored_from_snap));
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_HANDLE_WRITE_FAIL,
                         "Unable to write restored_from_snap");
                 goto out;
         }
@@ -797,19 +818,23 @@ glusterd_volume_write_snap_details (int fd, glusterd_volinfo_t *volinfo)
         ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_MAX_HARD_LIMIT,
                                    buf);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_HARD_LIMIT_SET_FAIL,
                         "Unable to write snap-max-hard-limit");
                 goto out;
         }
 
         ret = glusterd_store_snapd_info (volinfo);
         if (ret)
-                gf_log (this->name, GF_LOG_ERROR, "snapd info store failed "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAPD_INFO_STORE_FAIL, "snapd info store failed "
                         "volume: %s", volinfo->volname);
 
 out:
         if (ret)
-                gf_log (this->name, GF_LOG_ERROR, "Failed to write snap details"
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAPINFO_WRITE_FAIL,
+                        "Failed to write snap details"
                         " for volume %s", volinfo->volname);
         return ret;
 }
@@ -988,7 +1013,8 @@ glusterd_volume_exclude_options_write (int fd, glusterd_volinfo_t *volinfo)
 
 out:
         if (ret)
-                gf_log (this->name, GF_LOG_ERROR, "Unable to write volume "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_VOL_VALS_WRITE_FAIL, "Unable to write volume "
                         "values for %s", volinfo->volname);
         return ret;
 }
@@ -1018,7 +1044,7 @@ glusterd_store_create_volume_dir (glusterd_volinfo_t *volinfo)
                                        sizeof (voldirpath));
         ret = gf_store_mkdir (voldirpath);
 
-        gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug (THIS->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -1037,7 +1063,8 @@ glusterd_store_create_snap_dir (glusterd_snap_t *snap)
 
         ret = mkdir_p (snapdirpath, 0755, _gf_true);
         if (ret) {
-                gf_log (THIS->name, GF_LOG_ERROR, "Failed to create snaps dir "
+                gf_msg (THIS->name, GF_LOG_ERROR, errno,
+                        GD_MSG_CREATE_DIR_FAILED, "Failed to create snaps dir "
                         "%s", snapdirpath);
         }
         return ret;
@@ -1063,7 +1090,7 @@ glusterd_store_volinfo_write (int fd, glusterd_volinfo_t *volinfo)
         dict_foreach (volinfo->gsync_slaves, _storeslaves, shandle);
         shandle->fd = 0;
 out:
-        gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (THIS->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -1106,7 +1133,7 @@ glusterd_store_snapinfo_write (glusterd_snap_t *snap)
         ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_SNAP_TIMESTAMP, buf);
 
 out:
-        gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (THIS->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -1284,7 +1311,7 @@ glusterd_store_brickinfos (glusterd_volinfo_t *volinfo, int vol_fd)
                 brick_count++;
         }
 out:
-        gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (THIS->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -1342,7 +1369,7 @@ glusterd_store_node_state_write (int fd, glusterd_volinfo_t *volinfo)
                               &fd);
         }
 out:
-        gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (THIS->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -1370,7 +1397,7 @@ glusterd_store_perform_node_state_store (glusterd_volinfo_t *volinfo)
 out:
         if (ret && (fd > 0))
                 gf_store_unlink_tmppath (volinfo->node_state_shandle);
-        gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (THIS->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -1398,7 +1425,7 @@ glusterd_store_perform_volume_store (glusterd_volinfo_t *volinfo)
 out:
         if (ret && (fd > 0))
                 gf_store_unlink_tmppath (volinfo->shandle);
-        gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (THIS->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -1475,8 +1502,9 @@ glusterd_store_volinfo_atomic_update (glusterd_volinfo_t *volinfo)
 
 out:
         if (ret)
-                gf_log (THIS->name, GF_LOG_ERROR, "Couldn't rename "
-                        "temporary file(s): Reason %s", strerror (errno));
+                gf_msg (THIS->name, GF_LOG_ERROR, errno,
+                        GD_MSG_FILE_OP_FAILED, "Couldn't rename "
+                        "temporary file(s)");
         return ret;
 }
 
@@ -1504,8 +1532,9 @@ glusterd_store_snap_atomic_update (glusterd_snap_t *snap)
 
         ret = gf_store_rename_tmppath (snap->shandle);
         if (ret)
-                gf_log (THIS->name, GF_LOG_ERROR, "Couldn't rename "
-                        "temporary file(s): Reason %s", strerror (errno));
+                gf_msg (THIS->name, GF_LOG_ERROR, errno,
+                        GD_MSG_FILE_OP_FAILED, "Couldn't rename "
+                        "temporary file(s)");
 
         return ret;
 }
@@ -1519,26 +1548,34 @@ glusterd_store_snap (glusterd_snap_t *snap)
 
         ret = glusterd_store_create_snap_dir (snap);
         if (ret) {
-                gf_log (THIS->name, GF_LOG_ERROR, "Failed to create snap dir");
+                gf_msg (THIS->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAPDIR_CREATE_FAIL,
+                        "Failed to create snap dir");
                 goto out;
         }
 
         ret = glusterd_store_create_snap_shandle_on_absence (snap);
         if (ret) {
-                gf_log (THIS->name, GF_LOG_ERROR, "Failed to create snap info "
+                gf_msg (THIS->name, GF_LOG_ERROR, 0,
+                       GD_MSG_SNAPINFO_CREATE_FAIL,
+                       "Failed to create snap info "
                         "file");
                 goto out;
         }
 
         ret = glusterd_store_snapinfo_write (snap);
         if (ret) {
-                gf_log (THIS->name, GF_LOG_ERROR, "Failed to write snap info");
+                gf_msg (THIS->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAPINFO_WRITE_FAIL,
+                        "Failed to write snap info");
                 goto out;
         }
 
         ret = glusterd_store_snap_atomic_update (snap);
         if (ret) {
-                gf_log (THIS->name, GF_LOG_ERROR,"Failed to do automic update");
+                gf_msg (THIS->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAP_AUTOMIC_UPDATE_FAIL,
+                        "Failed to do automic update");
                 goto out;
         }
 
@@ -1546,7 +1583,7 @@ out:
         if (ret && snap->shandle)
                 gf_store_unlink_tmppath (snap->shandle);
 
-        gf_log (THIS->name, GF_LOG_TRACE, "Returning %d", ret);
+        gf_msg_trace (THIS->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -1594,7 +1631,7 @@ out:
         if (ret)
                 glusterd_store_volume_cleanup_tmp (volinfo);
 
-        gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (THIS->name, 0, "Returning %d", ret);
 
         return ret;
 }
@@ -1629,15 +1666,17 @@ glusterd_store_delete_volume (glusterd_volinfo_t *volinfo)
 
         ret = mkdir (trashdir, 0777);
         if (ret && errno != EEXIST) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to create trash "
-                        "directory, reason : %s", strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_CREATE_DIR_FAILED, "Failed to create trash "
+                        "directory");
                 ret = -1;
                 goto out;
         }
 
         ret = rename (pathname, delete_path);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to rename volume "
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_DIR_OP_FAILED, "Failed to rename volume "
                         "directory for volume %s", volinfo->volname);
                 rename_fail = _gf_true;
                 goto out;
@@ -1645,8 +1684,8 @@ glusterd_store_delete_volume (glusterd_volinfo_t *volinfo)
 
         ret = recursive_rmdir (trashdir);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s, Reason:"
-                        " %s", trashdir, strerror (errno));
+                gf_msg_debug (this->name, 0, "Failed to rmdir: %s",
+                                 trashdir);
         }
 
 out:
@@ -1656,7 +1695,7 @@ out:
         }
         ret = (rename_fail == _gf_true) ? -1: 0;
 
-        gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (this->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -1693,15 +1732,17 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
 
         ret = mkdir (trashdir, 0777);
         if (ret && errno != EEXIST) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to create trash "
-                        "directory, reason : %s", strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_CREATE_DIR_FAILED, "Failed to create trash "
+                        "directory");
                 ret = -1;
                 goto out;
         }
 
         ret = rename (pathname, delete_path);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to rename snap "
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_DIR_OP_FAILED, "Failed to rename snap "
                         "directory %s to %s", pathname, delete_path);
                 rename_fail = _gf_true;
                 goto out;
@@ -1709,8 +1750,8 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
 
         dir = opendir (delete_path);
         if (!dir) {
-                gf_log (this->name, GF_LOG_DEBUG, "Failed to open directory %s."
-                        " Reason : %s", delete_path, strerror (errno));
+                gf_msg_debug (this->name, 0, "Failed to open directory %s.",
+                                 delete_path);
                 ret = 0;
                 goto out;
         }
@@ -1720,8 +1761,8 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
                 snprintf (path, PATH_MAX, "%s/%s", delete_path, entry->d_name);
                 ret = stat (path, &st);
                 if (ret == -1) {
-                        gf_log (this->name, GF_LOG_DEBUG, "Failed to stat "
-                                "entry %s : %s", path, strerror (errno));
+                        gf_msg_debug (this->name, 0, "Failed to stat "
+                                "entry %s", path);
                         goto stat_failed;
                 }
 
@@ -1731,11 +1772,11 @@ glusterd_store_delete_snap (glusterd_snap_t *snap)
                         ret = unlink (path);
 
                 if (ret) {
-                        gf_log (this->name, GF_LOG_DEBUG, " Failed to remove "
-                                "%s. Reason : %s", path, strerror (errno));
+                        gf_msg_debug (this->name, 0, " Failed to remove "
+                                "%s", path);
                 }
 
-                gf_log (this->name, GF_LOG_DEBUG, "%s %s",
+                gf_msg_debug (this->name, 0, "%s %s",
                                 ret ? "Failed to remove":"Removed",
                                 entry->d_name);
 stat_failed:
@@ -1745,19 +1786,19 @@ stat_failed:
 
         ret = closedir (dir);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG, "Failed to close dir %s. "
-                        "Reason : %s",delete_path, strerror (errno));
+                gf_msg_debug (this->name, 0, "Failed to close dir %s.",
+                                delete_path);
         }
 
         ret = rmdir (delete_path);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s,err: %s",
-                        delete_path, strerror (errno));
+                gf_msg_debug (this->name, 0, "Failed to rmdir: %s",
+                        delete_path);
         }
         ret = rmdir (trashdir);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG, "Failed to rmdir: %s, Reason:"
-                        " %s", trashdir, strerror (errno));
+                gf_msg_debug (this->name, 0, "Failed to rmdir: %s",
+                                 trashdir);
         }
 
 out:
@@ -1767,7 +1808,7 @@ out:
         }
         ret = (rename_fail == _gf_true) ? -1: 0;
 
-        gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (this->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -1793,7 +1834,8 @@ glusterd_store_global_info (xlator_t *this)
                           GLUSTERD_INFO_FILE);
                 ret = gf_store_handle_new (path, &handle);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_STORE_HANDLE_GET_FAIL,
                                 "Unable to get store handle");
                         goto out;
                 }
@@ -1805,8 +1847,9 @@ glusterd_store_global_info (xlator_t *this)
         /* These options need to be available for all users */
         ret = chmod (handle->path, 0644);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "chmod error for %s: %s",
-                        GLUSTERD_INFO_FILE, strerror (errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_FILE_OP_FAILED, "chmod error for %s",
+                        GLUSTERD_INFO_FILE);
                 goto out;
         }
 
@@ -1819,7 +1862,8 @@ glusterd_store_global_info (xlator_t *this)
         ret = gf_store_save_value (handle->fd, GLUSTERD_STORE_UUID_KEY,
                                    uuid_str);
         if (ret) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, 0,
+                        GD_MSG_UUID_SET_FAIL,
                         "Storing uuid failed ret = %d", ret);
                 goto out;
         }
@@ -1828,7 +1872,8 @@ glusterd_store_global_info (xlator_t *this)
         ret = gf_store_save_value (handle->fd, GD_OP_VERSION_KEY,
                                    op_version_str);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_OP_VERS_STORE_FAIL,
                         "Storing op-version failed ret = %d", ret);
                 goto out;
         }
@@ -1848,7 +1893,8 @@ out:
                 GF_FREE (uuid_str);
 
         if (ret)
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_GLUSTERD_GLOBAL_INFO_STORE_FAIL,
                         "Failed to store glusterd global-info");
 
         return ret;
@@ -1873,7 +1919,7 @@ glusterd_retrieve_op_version (xlator_t *this, int *op_version)
                 ret = gf_store_handle_retrieve (path, &handle);
 
                 if (ret) {
-                        gf_log ("", GF_LOG_DEBUG, "Unable to get store "
+                        gf_msg_debug (this->name, 0, "Unable to get store "
                                 "handle!");
                         goto out;
                 }
@@ -1884,14 +1930,15 @@ glusterd_retrieve_op_version (xlator_t *this, int *op_version)
         ret = gf_store_retrieve_value (priv->handle, GD_OP_VERSION_KEY,
                                        &op_version_str);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG,
+                gf_msg_debug (this->name, 0,
                         "No previous op_version present");
                 goto out;
         }
 
         tmp_version = strtol (op_version_str, &tmp, 10);
         if ((tmp_version <= 0) || (tmp && strlen (tmp) > 1)) {
-                gf_log (this->name, GF_LOG_WARNING, "invalid version number");
+                gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+                        GD_MSG_UNSUPPORTED_VERSION, "invalid version number");
                 goto out;
         }
 
@@ -1930,7 +1977,7 @@ glusterd_retrieve_sys_snap_max_limit (xlator_t *this, uint64_t *limit,
                 ret = gf_store_handle_retrieve (path, &handle);
 
                 if (ret) {
-                        gf_log ("", GF_LOG_DEBUG, "Unable to get store "
+                        gf_msg_debug (this->name, 0, "Unable to get store "
                                 "handle!");
                         goto out;
                 }
@@ -1942,14 +1989,15 @@ glusterd_retrieve_sys_snap_max_limit (xlator_t *this, uint64_t *limit,
                                        key,
                                        &limit_str);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG,
+                gf_msg_debug (this->name, 0,
                         "No previous %s present", key);
                 goto out;
         }
 
         tmp_limit = strtoul (limit_str, &tmp, 10);
         if ((tmp_limit <= 0) || (tmp && strlen (tmp) > 1)) {
-                gf_log (this->name, GF_LOG_WARNING, "invalid version number");
+                gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+                        GD_MSG_UNSUPPORTED_VERSION, "invalid version number");
                 goto out;
         }
 
@@ -1976,7 +2024,8 @@ glusterd_restore_op_version (xlator_t *this)
         if (!ret) {
                 if ((op_version < GD_OP_VERSION_MIN) ||
                     (op_version > GD_OP_VERSION_MAX)) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+                                GD_MSG_UNSUPPORTED_VERSION,
                                 "wrong op-version (%d) retrieved", op_version);
                         ret = -1;
                         goto out;
@@ -2022,9 +2071,11 @@ glusterd_retrieve_uuid ()
         int32_t         ret = -1;
         gf_store_handle_t *handle = NULL;
         glusterd_conf_t *priv = NULL;
+        xlator_t        *this = NULL;
         char            path[PATH_MAX] = {0,};
 
-        priv = THIS->private;
+        this = THIS;
+        priv = this->private;
 
         if (!priv->handle) {
                 snprintf (path, PATH_MAX, "%s/%s", priv->workdir,
@@ -2032,7 +2083,7 @@ glusterd_retrieve_uuid ()
                 ret = gf_store_handle_retrieve (path, &handle);
 
                 if (ret) {
-                        gf_log ("", GF_LOG_DEBUG, "Unable to get store"
+                        gf_msg_debug (this->name, 0, "Unable to get store"
                                 "handle!");
                         goto out;
                 }
@@ -2044,7 +2095,7 @@ glusterd_retrieve_uuid ()
                                        &uuid_str);
 
         if (ret) {
-                gf_log ("", GF_LOG_DEBUG, "No previous uuid is present");
+                gf_msg_debug (this->name, 0, "No previous uuid is present");
                 goto out;
         }
 
@@ -2052,7 +2103,7 @@ glusterd_retrieve_uuid ()
 
 out:
         GF_FREE (uuid_str);
-        gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (this->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -2107,20 +2158,23 @@ glusterd_store_retrieve_snapd (glusterd_volinfo_t *volinfo)
 
         ret = gf_store_handle_retrieve (path, &volinfo->snapd.handle);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "volinfo handle is NULL");
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_HANDLE_NULL, "volinfo handle is NULL");
                 goto out;
         }
 
         ret = gf_store_iter_new (volinfo->snapd.handle, &iter);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to get new store "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_ITER_GET_FAIL, "Failed to get new store "
                         "iter");
                 goto out;
         }
 
         ret = gf_store_iter_get_next (iter, &key, &value, &op_errno);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to get next store "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_ITER_GET_FAIL, "Failed to get next store "
                         "iter");
                 goto out;
         }
@@ -2140,7 +2194,9 @@ glusterd_store_retrieve_snapd (glusterd_volinfo_t *volinfo)
 
         ret = gf_store_iter_destroy (iter);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to destroy store "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_ITER_DESTROY_FAIL,
+                        "Failed to destroy store "
                         "iter");
                 goto out;
         }
@@ -2167,13 +2223,15 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
         gf_store_iter_t         *tmpiter = NULL;
         char                    *tmpvalue = NULL;
         struct pmap_registry    *pmap = NULL;
+        xlator_t                *this = NULL;
         int                      brickid = 0;
         gf_store_op_errno_t     op_errno = GD_STORE_SUCCESS;
 
         GF_ASSERT (volinfo);
         GF_ASSERT (volinfo->volname);
 
-        priv = THIS->private;
+        this = THIS;
+        priv = this->private;
 
         GLUSTERD_GET_BRICK_DIR (brickdir, volinfo, priv);
 
@@ -2208,9 +2266,9 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
 
                 ret = gf_store_iter_get_next (iter, &key, &value, &op_errno);
                 if (ret) {
-                        gf_log ("glusterd", GF_LOG_ERROR, "Unable to iterate "
-                                "the store for brick: %s, reason: %s", path,
-                                gf_store_strerror (op_errno));
+                        gf_msg ("glusterd", GF_LOG_ERROR, op_errno,
+                                GD_MSG_STORE_ITER_GET_FAIL, "Unable to iterate "
+                                "the store for brick: %s", path);
                         goto out;
                 }
                 while (!ret) {
@@ -2286,7 +2344,8 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
                                 strncpy (brickinfo->brick_id, value,
                                          sizeof (brickinfo->brick_id));
                         } else {
-                                gf_log ("", GF_LOG_ERROR, "Unknown key: %s",
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_UNKNOWN_KEY, "Unknown key: %s",
                                         key);
                         }
 
@@ -2300,7 +2359,9 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
                 }
 
                 if (op_errno != GD_STORE_EOF) {
-                        gf_log ("", GF_LOG_ERROR, "Error parsing brickinfo: "
+                        gf_msg (this->name, GF_LOG_ERROR, op_errno,
+                                GD_MSG_PARSE_BRICKINFO_FAIL,
+                                "Error parsing brickinfo: "
                                 "op_errno=%d", op_errno);
                         goto out;
                 }
@@ -2323,7 +2384,7 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
         if (ret)
                 goto out;
 out:
-        gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug (this->name, 0, "Returning with %d", ret);
 
         return ret;
 }
@@ -2390,15 +2451,17 @@ glusterd_store_retrieve_node_state (glusterd_volinfo_t *volinfo)
                         dup_value = gf_strdup (value);
                         if (!dup_value) {
                                 ret = -1;
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+                                        GD_MSG_NO_MEMORY,
                                         "Failed to strdup value string");
                                 goto out;
                         }
                         ret = dict_set_str (tmp_dict, key, dup_value);
                         if (ret) {
-                                gf_log (this->name, GF_LOG_ERROR,
-                                                "Error setting data in rebal "
-                                                "dict.");
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_DICT_SET_FAILED,
+                                        "Error setting data in rebal "
+                                        "dict.");
                                 goto out;
                         }
                         dup_value = NULL;
@@ -2432,7 +2495,7 @@ out:
         if (tmp_dict)
                 dict_unref (tmp_dict);
 
-        gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+        gf_msg_trace (this->name, 0, "Returning with %d", ret);
 
         return ret;
 }
@@ -2464,26 +2527,29 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
 
         ret = gf_store_handle_retrieve (path, &volinfo->shandle);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "volinfo handle is NULL");
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_HANDLE_NULL, "volinfo handle is NULL");
                 goto out;
         }
 
         ret = gf_store_iter_new (volinfo->shandle, &iter);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to get new store "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_ITER_GET_FAIL, "Failed to get new store "
                         "iter");
                 goto out;
         }
 
         ret = gf_store_iter_get_next (iter, &key, &value, &op_errno);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to get next store "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_ITER_GET_FAIL, "Failed to get next store "
                         "iter");
                 goto out;
         }
 
         while (!ret) {
-                gf_log ("", GF_LOG_DEBUG, "key = %s value = %s", key, value);
+                gf_msg_debug (this->name, 0, "key = %s value = %s", key, value);
                 if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_TYPE,
                               strlen (GLUSTERD_STORE_KEY_VOL_TYPE))) {
                         volinfo->type = atoi (value);
@@ -2521,7 +2587,8 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
                                      strlen (GLUSTERD_STORE_KEY_VOL_ID))) {
                         ret = gf_uuid_parse (value, volinfo->volume_id);
                         if (ret)
-                                gf_log ("", GF_LOG_WARNING,
+                                gf_msg (this->name, GF_LOG_WARNING, 0,
+                                        GD_MSG_UUID_PARSE_FAIL,
                                         "failed to parse uuid");
 
                 } else if (!strncmp (key, GLUSTERD_STORE_KEY_USERNAME,
@@ -2538,11 +2605,12 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
                         ret = dict_set_dynstr (volinfo->gsync_slaves, key,
                                                 gf_strdup (value));
                         if (ret) {
-                                gf_log ("",GF_LOG_ERROR, "Error in "
-                                                "dict_set_str");
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_DICT_SET_FAILED, "Error in "
+                                        "dict_set_str");
                                 goto out;
                         }
-                        gf_log ("", GF_LOG_DEBUG, "Parsed as "GEOREP" "
+                        gf_msg_debug (this->name, 0, "Parsed as "GEOREP" "
                                 " slave:key=%s,value:%s", key, value);
 
                 } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_OP_VERSION,
@@ -2561,7 +2629,8 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
                               strlen (GLUSTERD_STORE_KEY_VOL_RESTORED_SNAP))) {
                         ret = gf_uuid_parse (value, volinfo->restored_from_snap);
                         if (ret)
-                                gf_log (this->name, GF_LOG_WARNING,
+                                gf_msg (this->name, GF_LOG_WARNING, 0,
+                                        GD_MSG_UUID_PARSE_FAIL,
                                         "failed to parse restored snap's uuid");
                 } else if (!strncmp (key, GLUSTERD_STORE_KEY_PARENT_VOLNAME,
                                 strlen (GLUSTERD_STORE_KEY_PARENT_VOLNAME))) {
@@ -2611,7 +2680,8 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
                                  /*Ignore GLUSTERD_STORE_KEY_VOL_BRICK since
                                   glusterd_store_retrieve_bricks gets it later*/
                                 if (!strstr (key, GLUSTERD_STORE_KEY_VOL_BRICK))
-                                        gf_log ("", GF_LOG_WARNING,
+                                        gf_msg (this->name, GF_LOG_WARNING, 0,
+                                                GD_MSG_UNKNOWN_KEY,
                                                 "Unknown key: %s", key);
                                 break;
 
@@ -2627,11 +2697,13 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
                                 ret = dict_set_str(volinfo->dict, key,
                                                    gf_strdup (value));
                                 if (ret) {
-                                        gf_log ("",GF_LOG_ERROR, "Error in "
+                                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                                GD_MSG_DICT_SET_FAILED,
+                                                "Error in "
                                                 "dict_set_str");
                                         goto out;
                                 }
-                                gf_log ("", GF_LOG_DEBUG, "Parsed as Volume-"
+                                gf_msg_debug (this->name, 0, "Parsed as Volume-"
                                         "set:key=%s,value:%s", key, value);
                                 break;
                         }
@@ -2702,7 +2774,9 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo)
 
         ret = gf_store_iter_destroy (iter);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to destroy store "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_ITER_DESTROY_FAIL,
+                        "Failed to destroy store "
                         "iter");
                 goto out;
         }
@@ -2747,7 +2821,8 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
 
         ret = glusterd_store_update_volinfo (volinfo);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to update volinfo "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_VOLINFO_UPDATE_FAIL, "Failed to update volinfo "
                         "for %s volume", volname);
                 goto out;
         }
@@ -2789,7 +2864,8 @@ glusterd_store_retrieve_volume (char *volname, glusterd_snap_t *snap)
                 ret = glusterd_volinfo_find (volinfo->parent_volname,
                                              &origin_volinfo);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR, "Parent volinfo "
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_VOLINFO_GET_FAIL, "Parent volinfo "
                                 "not found for %s volume", volname);
                         goto out;
                 }
@@ -2803,7 +2879,7 @@ out:
                 volinfo = NULL;
         }
 
-        gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+        gf_msg_trace (this->name, 0, "Returning with %d", ret);
 
         return volinfo;
 }
@@ -2929,7 +3005,8 @@ glusterd_store_retrieve_volumes (xlator_t  *this, glusterd_snap_t *snap)
         dir = opendir (path);
 
         if (!dir) {
-                gf_log ("", GF_LOG_ERROR, "Unable to open dir %s", path);
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_DIR_OP_FAILED, "Unable to open dir %s", path);
                 goto out;
         }
 
@@ -2942,7 +3019,8 @@ glusterd_store_retrieve_volumes (xlator_t  *this, glusterd_snap_t *snap)
 
                 volinfo = glusterd_store_retrieve_volume (entry->d_name, snap);
                 if (!volinfo) {
-                        gf_log ("", GF_LOG_ERROR, "Unable to restore "
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_VOL_RESTORE_FAIL, "Unable to restore "
                                 "volume: %s", entry->d_name);
                         ret = -1;
                         goto out;
@@ -2951,7 +3029,8 @@ glusterd_store_retrieve_volumes (xlator_t  *this, glusterd_snap_t *snap)
                 ret = glusterd_store_retrieve_node_state (volinfo);
                 if (ret) {
                         /* Backward compatibility */
-                        gf_log ("", GF_LOG_INFO, "Creating a new node_state "
+                        gf_log (this->name, GF_LOG_INFO,
+                                "Creating a new node_state "
                                 "for volume: %s.", entry->d_name);
                         glusterd_store_create_nodestate_sh_on_absence (volinfo);
                         ret = glusterd_store_perform_node_state_store (volinfo);
@@ -2966,7 +3045,7 @@ next:
 out:
         if (dir)
                 closedir (dir);
-        gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug (this->name, 0, "Returning with %d", ret);
 
         return ret;
 }
@@ -2999,7 +3078,8 @@ glusterd_find_brick_mount_path (char *brick_path, char **brick_mount_path)
                 /* Snapshot bricks must have brick num as part
                  * of the brickpath
                  */
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+                        GD_MSG_INVALID_ENTRY,
                         "Invalid brick path(%s)", brick_path);
                 ret = -1;
                 goto out;
@@ -3023,7 +3103,7 @@ out:
                 GF_FREE (*brick_mount_path);
                 *brick_mount_path = NULL;
         }
-        gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+        gf_msg_trace (this->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -3071,24 +3151,26 @@ glusterd_mount_brick_paths (char *brick_mount_path,
                          NULL);
         ret = runner_run (&runner);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR,
-                        "Failed to activate %s. Error: %s",
-                        brickinfo->device_path, strerror(errno));
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_SNAP_ACTIVATE_FAIL,
+                        "Failed to activate %s.",
+                        brickinfo->device_path);
                 goto out;
         } else
-                gf_log (this->name, GF_LOG_DEBUG,
+                gf_msg_debug (this->name, 0,
                         "Activating %s successful", brickinfo->device_path);
 
         /* Mount the snapshot */
         ret = glusterd_mount_lvm_snapshot (brickinfo, brick_mount_path);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAP_MOUNT_FAIL,
                         "Failed to mount lvm snapshot.");
                 goto out;
         }
 
 out:
-        gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+        gf_msg_trace (this->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -3118,7 +3200,8 @@ glusterd_recreate_vol_brick_mounts (xlator_t  *this,
                 ret = glusterd_find_brick_mount_path (brickinfo->path,
                                                       &brick_mount_path);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_BRK_MNTPATH_GET_FAIL,
                                 "Failed to find brick_mount_path for %s",
                                 brickinfo->path);
                         goto out;
@@ -3132,17 +3215,17 @@ glusterd_recreate_vol_brick_mounts (xlator_t  *this,
                                 ret = mkdir_p (brick_mount_path, 0777,
                                                _gf_true);
                                 if (ret) {
-                                        gf_log (this->name, GF_LOG_ERROR,
-                                                "Failed to create %s. "
-                                                "Error: %s", brick_mount_path,
-                                                strerror (errno));
+                                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                                GD_MSG_CREATE_DIR_FAILED,
+                                                "Failed to create %s. ",
+                                                 brick_mount_path);
                                         goto out;
                                 }
                         } else {
-                                gf_log (this->name, GF_LOG_ERROR,
-                                        "Brick Path(%s) not valid. "
-                                        "Error: %s", brickinfo->path,
-                                        strerror(errno));
+                                gf_msg (this->name, GF_LOG_ERROR, errno,
+                                        GD_MSG_FILE_OP_FAILED,
+                                        "Brick Path(%s) not valid. ",
+                                         brickinfo->path);
                                 goto out;
                         }
                 }
@@ -3151,7 +3234,8 @@ glusterd_recreate_vol_brick_mounts (xlator_t  *this,
                  * If not, mount the device_path at the brick_mount_path */
                 ret = glusterd_mount_brick_paths (brick_mount_path, brickinfo);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_BRK_MNTPATH_MOUNT_FAIL,
                                 "Failed to mount brick_mount_path");
                 }
 
@@ -3166,7 +3250,7 @@ out:
         if (ret && brick_mount_path)
                 GF_FREE (brick_mount_path);
 
-        gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+        gf_msg_trace (this->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -3185,7 +3269,8 @@ glusterd_resolve_snap_bricks (xlator_t  *this, glusterd_snap_t *snap)
                                          brick_list) {
                         ret = glusterd_resolve_brick (brickinfo);
                         if (ret) {
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_RESOLVE_BRICK_FAIL,
                                         "resolve brick failed in restore");
                                 goto out;
                         }
@@ -3195,7 +3280,7 @@ glusterd_resolve_snap_bricks (xlator_t  *this, glusterd_snap_t *snap)
         ret = 0;
 
 out:
-        gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+        gf_msg_trace (this->name, 0, "Returning with %d", ret);
 
         return ret;
 }
@@ -3224,33 +3309,37 @@ glusterd_store_update_snap (glusterd_snap_t *snap)
 
         ret = gf_store_handle_retrieve (path, &snap->shandle);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "snap handle is NULL");
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_HANDLE_NULL, "snap handle is NULL");
                 goto out;
         }
 
         ret = gf_store_iter_new (snap->shandle, &iter);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to get new store "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_ITER_GET_FAIL, "Failed to get new store "
                         "iter");
                 goto out;
         }
 
         ret = gf_store_iter_get_next (iter, &key, &value, &op_errno);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to get next store "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_ITER_GET_FAIL, "Failed to get next store "
                         "iter");
                 goto out;
         }
 
         while (!ret) {
-                gf_log (this->name, GF_LOG_DEBUG, "key = %s value = %s",
+                gf_msg_debug (this->name, 0, "key = %s value = %s",
                         key, value);
 
                 if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_ID,
                                      strlen (GLUSTERD_STORE_KEY_SNAP_ID))) {
                         ret = gf_uuid_parse (value, snap->snap_id);
                         if (ret)
-                                gf_log (this->name, GF_LOG_WARNING,
+                                gf_msg (this->name, GF_LOG_WARNING, 0,
+                                        GD_MSG_UUID_PARSE_FAIL,
                                         "Failed to parse uuid");
                 } else if (!strncmp (key, GLUSTERD_STORE_KEY_SNAP_RESTORED,
                                    strlen (GLUSTERD_STORE_KEY_SNAP_RESTORED))) {
@@ -3279,7 +3368,9 @@ glusterd_store_update_snap (glusterd_snap_t *snap)
 
         ret = gf_store_iter_destroy (iter);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to destroy store "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_ITER_DESTROY_FAIL,
+                        "Failed to destroy store "
                         "iter");
         }
 
@@ -3302,22 +3393,26 @@ glusterd_store_retrieve_snap (char *snapname)
 
         snap = glusterd_new_snap_object ();
         if (!snap) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to create "
-                                                  " snap object");
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAP_OBJECT_STORE_FAIL, "Failed to create "
+                        " snap object");
                 goto out;
         }
 
         strncpy (snap->snapname, snapname, strlen(snapname));
         ret = glusterd_store_update_snap (snap);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to update snapshot "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAPSHOT_UPDATE_FAIL,
+                        "Failed to update snapshot "
                         "for %s snap", snapname);
                 goto out;
         }
 
         ret = glusterd_store_retrieve_volumes (this, snap);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to retrieve "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAP_VOL_RETRIEVE_FAIL, "Failed to retrieve "
                         "snap volumes for snap %s", snapname);
                 goto out;
         }
@@ -3329,7 +3424,7 @@ glusterd_store_retrieve_snap (char *snapname)
                                  glusterd_compare_snap_time);
 
 out:
-        gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+        gf_msg_trace (this->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -3363,11 +3458,13 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t  *this)
         if (!fp) {
                 /* If errno is ENOENT then there are no missed snaps yet */
                 if (errno != ENOENT) {
-                        gf_log (this->name, GF_LOG_ERROR,
-                                "Failed to open %s. "
-                                "Error: %s", path, strerror(errno));
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                GD_MSG_FILE_OP_FAILED,
+                                "Failed to open %s. ",
+                                path);
                 } else {
-                        gf_log (this->name, GF_LOG_INFO,
+                        gf_msg (this->name, GF_LOG_INFO, 0,
+                                GD_MSG_MISSED_SNAP_LIST_EMPTY,
                                 "No missed snaps list.");
                         ret = 0;
                 }
@@ -3380,16 +3477,16 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t  *this)
                                                   &store_errno);
                 if (ret) {
                         if (store_errno == GD_STORE_EOF) {
-                                gf_log (this->name,
-                                        GF_LOG_DEBUG,
+                                gf_msg_debug (this->name,
+                                        0,
                                         "EOF for missed_snap_list");
                                 ret = 0;
                                 break;
                         }
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, store_errno,
+                                GD_MSG_MISSED_SNAP_GET_FAIL,
                                 "Failed to fetch data from "
-                                "missed_snaps_list. Error: %s",
-                                gf_store_strerror (store_errno));
+                                "missed_snaps_list.");
                         goto out;
                 }
 
@@ -3403,7 +3500,8 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t  *this)
                 if (!missed_node_info || !brick_path || !snap_vol_id ||
                     brick_num < 1 || snap_op < 1 ||
                     snap_status < 1) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, EINVAL,
+                                GD_MSG_INVALID_MISSED_SNAP_ENTRY,
                                 "Invalid missed_snap_entry");
                         ret = -1;
                         goto out;
@@ -3416,7 +3514,8 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t  *this)
                                                       snap_op,
                                                       snap_status);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_MISSED_SNAP_LIST_STORE_FAIL,
                                 "Failed to store missed snaps_list");
                         goto out;
                 }
@@ -3425,7 +3524,7 @@ glusterd_store_retrieve_missed_snaps_list (xlator_t  *this)
 
         ret = 0;
 out:
-        gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+        gf_msg_trace (this->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -3452,7 +3551,9 @@ glusterd_store_retrieve_snaps (xlator_t  *this)
                    backward compatibility */
                 if (errno != ENOENT) {
                         ret = -1;
-                        gf_log ("", GF_LOG_ERROR, "Unable to open dir %s", path);
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                GD_MSG_DIR_OP_FAILED, "Unable to open dir %s",
+                                path);
                 }
                 goto out;
         }
@@ -3463,7 +3564,8 @@ glusterd_store_retrieve_snaps (xlator_t  *this)
                 if (strcmp (entry->d_name, GLUSTERD_MISSED_SNAPS_LIST_FILE)) {
                         ret = glusterd_store_retrieve_snap (entry->d_name);
                         if (ret) {
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_SNAP_RESTORE_FAIL,
                                         "Unable to restore snapshot: %s",
                                         entry->d_name);
                                 goto out;
@@ -3475,7 +3577,7 @@ glusterd_store_retrieve_snaps (xlator_t  *this)
         /* Retrieve missed_snaps_list */
         ret = glusterd_store_retrieve_missed_snaps_list (this);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG,
+                gf_msg_debug (this->name, 0,
                         "Failed to retrieve missed_snaps_list");
                 goto out;
         }
@@ -3483,7 +3585,7 @@ glusterd_store_retrieve_snaps (xlator_t  *this)
 out:
         if (dir)
                 closedir (dir);
-        gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug (this->name, 0, "Returning with %d", ret);
 
         return ret;
 }
@@ -3522,7 +3624,8 @@ glusterd_store_write_missed_snapinfo (int32_t fd)
                                   snap_opinfo->op, snap_opinfo->status);
                         ret = gf_store_save_value (fd, key, value);
                         if (ret) {
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_MISSEDSNAP_INFO_SET_FAIL,
                                         "Failed to write missed snapinfo");
                                 goto out;
                         }
@@ -3531,7 +3634,7 @@ glusterd_store_write_missed_snapinfo (int32_t fd)
 
         ret = 0;
 out:
-        gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+        gf_msg_trace (this->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -3553,14 +3656,17 @@ glusterd_store_update_missed_snaps ()
 
         ret = glusterd_store_create_missed_snaps_list_shandle_on_absence ();
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Unable to obtain "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_MISSED_SNAP_LIST_STORE_HANDLE_GET_FAIL,
+                        "Unable to obtain "
                         "missed_snaps_list store handle.");
                 goto out;
         }
 
         fd = gf_store_mkstemp (priv->missed_snaps_list_shandle);
         if (fd <= 0) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_FILE_OP_FAILED,
                         "Failed to create tmp file");
                 ret = -1;
                 goto out;
@@ -3568,14 +3674,16 @@ glusterd_store_update_missed_snaps ()
 
         ret = glusterd_store_write_missed_snapinfo (fd);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_MISSED_SNAP_CREATE_FAIL,
                         "Failed to write missed snaps to disk");
                 goto out;
         }
 
         ret = gf_store_rename_tmppath (priv->missed_snaps_list_shandle);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_FILE_OP_FAILED,
                         "Failed to rename the tmp file");
                 goto out;
         }
@@ -3583,13 +3691,14 @@ out:
         if (ret && (fd > 0)) {
                 ret = gf_store_unlink_tmppath (priv->missed_snaps_list_shandle);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_TMP_FILE_UNLINK_FAIL,
                                 "Failed to unlink the tmp file");
                 }
                 ret = -1;
         }
 
-        gf_log (this->name, GF_LOG_TRACE, "Returning %d", ret);
+        gf_msg_trace (this->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -3598,6 +3707,7 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo)
 {
         int32_t                         ret = -1;
         glusterd_conf_t                 *priv = NULL;
+        xlator_t                        *this = NULL;
         char                            peerdir[PATH_MAX] = {0,};
         char                            filepath[PATH_MAX] = {0,};
         char                            hostname_path[PATH_MAX] = {0,};
@@ -3608,7 +3718,8 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo)
                 goto out;
         }
 
-        priv = THIS->private;
+        this = THIS;
+        priv = this->private;
 
         snprintf (peerdir, PATH_MAX, "%s/peers", priv->workdir);
 
@@ -3644,7 +3755,7 @@ out:
                 gf_store_handle_destroy (peerinfo->shandle);
                 peerinfo->shandle = NULL;
         }
-        gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug (this->name, 0, "Returning with %d", ret);
 
         return ret;
 }
@@ -3669,7 +3780,7 @@ glusterd_store_create_peer_dir ()
         glusterd_store_peerinfo_dirpath_set (path, sizeof (path));
         ret = gf_store_mkdir (path);
 
-        gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -3798,7 +3909,7 @@ glusterd_store_peer_write (int fd, glusterd_peerinfo_t *peerinfo)
         }
 
 out:
-        gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -3824,7 +3935,7 @@ glusterd_store_perform_peer_store (glusterd_peerinfo_t *peerinfo)
 out:
         if (ret && (fd > 0))
                 gf_store_unlink_tmppath (peerinfo->shandle);
-        gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug ("glusterd", 0, "Returning %d", ret);
         return ret;
 }
 
@@ -3845,7 +3956,7 @@ glusterd_store_peerinfo (glusterd_peerinfo_t *peerinfo)
 
         ret = glusterd_store_perform_peer_store (peerinfo);
 out:
-        gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -3879,7 +3990,9 @@ glusterd_store_retrieve_peers (xlator_t *this)
         dir = opendir (path);
 
         if (!dir) {
-                gf_log ("", GF_LOG_ERROR, "Unable to open dir %s", path);
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_DIR_OP_FAILED,
+                        "Unable to open dir %s", path);
                 ret = -1;
                 goto out;
         }
@@ -3925,7 +4038,8 @@ glusterd_store_retrieve_peers (xlator_t *this)
                                    strlen (GLUSTERD_STORE_KEY_PEER_HOSTNAME))) {
                                 ret = gd_add_address_to_peer (peerinfo, value);
                         } else {
-                                gf_log ("", GF_LOG_ERROR, "Unknown key: %s",
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_UNKNOWN_KEY, "Unknown key: %s",
                                         key);
                         }
 
@@ -3982,7 +4096,7 @@ out:
 
         if (dir)
                 closedir (dir);
-        gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
+        gf_msg_debug (this->name, 0, "Returning with %d", ret);
 
         return ret;
 }
@@ -4012,7 +4126,8 @@ glusterd_recreate_all_snap_brick_mounts (xlator_t  *this)
 
                 ret = glusterd_recreate_vol_brick_mounts (this, volinfo);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_BRK_MNT_RECREATE_FAIL,
                                 "Failed to recreate brick mounts "
                                 "for %s", volinfo->volname);
                         goto out;
@@ -4025,7 +4140,8 @@ glusterd_recreate_all_snap_brick_mounts (xlator_t  *this)
                         ret = glusterd_recreate_vol_brick_mounts (this,
                                                                   volinfo);
                         if (ret) {
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_BRK_MNT_RECREATE_FAIL,
                                         "Failed to recreate brick mounts "
                                         "for %s", snap->snapname);
                                 goto out;
@@ -4034,7 +4150,7 @@ glusterd_recreate_all_snap_brick_mounts (xlator_t  *this)
         }
 
 out:
-        gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+        gf_msg_trace (this->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -4066,7 +4182,8 @@ glusterd_snap_cleanup (xlator_t  *this)
 
         dict = dict_new();
         if (!dict) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_DICT_CREATE_FAIL,
                         "Failed to create dict");
                 ret = -1;
                 goto out;
@@ -4077,7 +4194,9 @@ glusterd_snap_cleanup (xlator_t  *this)
                 if (snap->snap_status == GD_SNAP_STATUS_RESTORED) {
                         ret = glusterd_snapshot_revert_restore_from_snap (snap);
                         if (ret) {
-                                gf_log (this->name, GF_LOG_WARNING, "Failed to "
+                                gf_msg (this->name, GF_LOG_WARNING, 0,
+                                        GD_MSG_SNAP_RESTORE_REVERT_FAIL,
+                                        "Failed to "
                                         "revert partially restored snapshot "
                                         "(%s)", snap->snapname);
                                 goto out;
@@ -4086,7 +4205,8 @@ glusterd_snap_cleanup (xlator_t  *this)
                         ret = glusterd_snap_remove (dict, snap,
                                                     _gf_true, _gf_true);
                         if (ret) {
-                                gf_log (this->name, GF_LOG_ERROR,
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        GD_MSG_SNAP_REMOVE_FAIL,
                                         "Failed to remove the snapshot %s",
                                         snap->snapname);
                                 goto out;
@@ -4097,7 +4217,7 @@ out:
         if (dict)
                 dict_unref (dict);
 
-        gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+        gf_msg_trace (this->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -4121,7 +4241,8 @@ glusterd_resolve_all_bricks (xlator_t  *this)
                                          brick_list) {
                         ret = glusterd_resolve_brick (brickinfo);
                         if (ret) {
-                                gf_log ("glusterd", GF_LOG_ERROR,
+                                gf_msg ("glusterd", GF_LOG_ERROR, 0,
+                                        GD_MSG_RESOLVE_BRICK_FAIL,
                                         "resolve brick failed in restore");
                                 goto out;
                         }
@@ -4132,7 +4253,8 @@ glusterd_resolve_all_bricks (xlator_t  *this)
         cds_list_for_each_entry (snap, &priv->snapshots, snap_list) {
                 ret = glusterd_resolve_snap_bricks (this, snap);
                 if (ret) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_SNAP_RESOLVE_BRICK_FAIL,
                                 "resolving the snap bricks"
                                 " failed for snap: %s",
                                 snap->snapname);
@@ -4141,7 +4263,7 @@ glusterd_resolve_all_bricks (xlator_t  *this)
         }
 
 out:
-        gf_log (this->name, GF_LOG_TRACE, "Returning with %d", ret);
+        gf_msg_trace (this->name, 0, "Returning with %d", ret);
         return ret;
 }
 
@@ -4179,20 +4301,22 @@ glusterd_restore ()
 
         ret = glusterd_snap_cleanup (this);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to perform "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAP_CLEANUP_FAIL, "Failed to perform "
                         "a cleanup of the snapshots");
                 goto out;
         }
 
         ret = glusterd_recreate_all_snap_brick_mounts (this);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to recreate "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_SNAP_BRK_MNT_RECREATE_FAIL, "Failed to recreate "
                         "all snap brick mounts");
                 goto out;
         }
 
 out:
-        gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug (this->name, 0, "Returning %d", ret);
         return ret;
 }
 
@@ -4220,22 +4344,24 @@ glusterd_store_retrieve_quota_version (glusterd_volinfo_t *volinfo)
 
         ret = gf_store_handle_new (cksum_path, &handle);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Unable to get store handle "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_STORE_HANDLE_GET_FAIL,
+                        "Unable to get store handle "
                         "for %s", cksum_path);
                 goto out;
         }
 
         ret = gf_store_retrieve_value (handle, "version", &version_str);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG, "Version absent");
+                gf_msg_debug (this->name, 0, "Version absent");
                 ret = 0;
                 goto out;
         }
 
         version = strtoul (version_str, &tmp, 10);
 	if ((errno == ERANGE) || (errno == EINVAL)) {
-                 gf_log (this->name, GF_LOG_DEBUG, "Invalid version number");
-                 goto out;
+                gf_msg_debug (this->name, 0, "Invalid version number");
+                goto out;
         }
         volinfo->quota_conf_version = version;
         ret = 0;
@@ -4279,7 +4405,8 @@ glusterd_store_save_quota_version_and_cksum (glusterd_volinfo_t *volinfo)
         snprintf (buf, sizeof (buf)-1, "%u", volinfo->quota_conf_cksum);
         ret = gf_store_save_value (fd, "cksum", buf);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to store cksum");
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_CKSUM_STORE_FAIL, "Failed to store cksum");
                 goto out;
         }
 
@@ -4287,7 +4414,8 @@ glusterd_store_save_quota_version_and_cksum (glusterd_volinfo_t *volinfo)
         snprintf (buf, sizeof (buf)-1, "%u", volinfo->quota_conf_version);
         ret = gf_store_save_value (fd, "version", buf);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to store version");
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_VERS_STORE_FAIL, "Failed to store version");
                 goto out;
         }
 
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 39160c0..57592c8 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -45,6 +45,7 @@
 #include "glusterd-scrub-svc.h"
 #include "glusterd-quotad-svc.h"
 #include "glusterd-snapd-svc.h"
+#include "glusterd-messages.h"
 #include "common-utils.h"
 #include "glusterd-geo-rep.h"
 #include "run.h"
@@ -159,7 +160,8 @@ glusterd_uuid_init ()
         ret = glusterd_uuid_generate_save ();
 
         if (ret) {
-                gf_log ("glusterd", GF_LOG_ERROR,
+                gf_msg ("glusterd", GF_LOG_ERROR, 0,
+                        GD_MSG_UUID_GEN_STORE_FAIL,
                           "Unable to generate and save new UUID");
                 return ret;
         }
@@ -187,7 +189,8 @@ glusterd_uuid_generate_save ()
         ret = glusterd_store_global_info (this);
 
         if (ret)
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_UUID_STORE_FAIL,
                         "Unable to store the generated uuid %s",
                         uuid_utoa (priv->uuid));
 
@@ -219,7 +222,8 @@ glusterd_options_init (xlator_t *this)
 
         ret = glusterd_store_options (this, priv->opts);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Unable to store version");
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_VERS_STORE_FAIL, "Unable to store version");
                 return ret;
         }
 out:
@@ -298,7 +302,8 @@ mem_acct_init (xlator_t *this)
         ret = xlator_mem_acct_init (this, gf_gld_mt_end + 1);
 
         if (ret != 0) {
-                gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+                gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+                        GD_MSG_NO_MEMORY, "Memory accounting init"
                         " failed");
                 return ret;
         }
@@ -315,7 +320,8 @@ glusterd_rpcsvc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
         glusterd_conf_t     *priv = NULL;
 
         if (!xl || !data) {
-                gf_log ("glusterd", GF_LOG_WARNING,
+                gf_msg ("glusterd", GF_LOG_WARNING, 0,
+                        GD_MSG_NO_INIT,
                         "Calling rpc_notify without initializing");
                 goto out;
         }
@@ -360,7 +366,7 @@ glusterd_program_register (xlator_t *this, rpcsvc_t *svc,
 
         ret = rpcsvc_program_register (svc, prog);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG,
+                gf_msg_debug (this->name, 0,
                         "cannot register program (name: %s, prognum:%d, "
                         "progver:%d)", prog->progname, prog->prognum,
                         prog->progver);
@@ -389,7 +395,7 @@ glusterd_rpcsvc_options_build (dict_t *options)
                         goto out;
         }
 
-        gf_log ("", GF_LOG_DEBUG, "listen-backlog value: %d", backlog);
+        gf_msg_debug ("", 0, "listen-backlog value: %d", backlog);
 
 out:
         return ret;
@@ -410,12 +416,14 @@ glusterd_check_gsync_present (int *valid_state)
         ret = runner_start (&runner);
         if (ret == -1) {
                 if (errno == ENOENT) {
-                        gf_log ("glusterd", GF_LOG_INFO, GEOREP
+                        gf_msg ("glusterd", GF_LOG_INFO, errno,
+                                GD_MSG_MODULE_NOT_INSTALLED, GEOREP
                                  " module not installed in the system");
                         *valid_state = 0;
                 }
                 else {
-                        gf_log ("glusterd", GF_LOG_ERROR, GEOREP
+                        gf_msg ("glusterd", GF_LOG_ERROR, errno,
+                                GD_MSG_MODULE_NOT_WORKING, GEOREP
                                   " module not working as desired");
                         *valid_state = -1;
                 }
@@ -426,14 +434,16 @@ glusterd_check_gsync_present (int *valid_state)
         if (ptr) {
                 if (!strstr (buff, "gsyncd")) {
                         ret = -1;
-                        gf_log ("glusterd", GF_LOG_ERROR, GEOREP" module not "
+                        gf_msg ("glusterd", GF_LOG_ERROR, 0,
+                                GD_MSG_MODULE_NOT_WORKING, GEOREP" module not "
                                  "working as desired");
                         *valid_state = -1;
                         goto out;
                 }
         } else {
                 ret = -1;
-                gf_log ("glusterd", GF_LOG_ERROR, GEOREP" module not "
+                gf_msg ("glusterd", GF_LOG_ERROR, 0,
+                        GD_MSG_MODULE_NOT_WORKING, GEOREP" module not "
                          "working as desired");
                 *valid_state = -1;
                 goto out;
@@ -444,7 +454,7 @@ glusterd_check_gsync_present (int *valid_state)
 
         runner_end (&runner);
 
-        gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug ("glusterd", 0, "Returning %d", ret);
         return ret;
 
 }
@@ -468,7 +478,8 @@ group_write_allow (char *path, gid_t gid)
 
  out:
         if (ret == -1)
-                gf_log ("", GF_LOG_CRITICAL,
+                gf_msg ("", GF_LOG_CRITICAL, errno,
+                        GD_MSG_WRITE_ACCESS_GRANT_FAIL,
                         "failed to set up write access to %s for group %d (%s)",
                         path, gid, strerror (errno));
         return ret;
@@ -486,7 +497,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf)
 
         if (strlen (conf->workdir)+2 > PATH_MAX-strlen(GEOREP)) {
                 ret = -1;
-                gf_log ("glusterd", GF_LOG_CRITICAL,
+                gf_msg ("glusterd", GF_LOG_CRITICAL, 0,
+                        GD_MSG_DIRPATH_TOO_LONG,
                         "directory path %s/"GEOREP" is longer than PATH_MAX",
                         conf->workdir);
                 goto out;
@@ -495,7 +507,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf)
         snprintf (georepdir, PATH_MAX, "%s/"GEOREP, conf->workdir);
         ret = mkdir_p (georepdir, 0777, _gf_true);
         if (-1 == ret) {
-                gf_log ("glusterd", GF_LOG_CRITICAL,
+                gf_msg ("glusterd", GF_LOG_CRITICAL, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "Unable to create "GEOREP" directory %s",
                         georepdir);
                 goto out;
@@ -503,14 +516,16 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf)
 
         if (strlen (DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP) >= PATH_MAX) {
                 ret = -1;
-                gf_log ("glusterd", GF_LOG_CRITICAL,
+                gf_msg ("glusterd", GF_LOG_CRITICAL, 0,
+                        GD_MSG_DIRPATH_TOO_LONG,
                         "directory path "DEFAULT_LOG_FILE_DIRECTORY"/"
                         GEOREP" is longer than PATH_MAX");
                 goto out;
         }
         ret = mkdir_p (DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP, 0777, _gf_true);
         if (-1 == ret) {
-                gf_log ("glusterd", GF_LOG_CRITICAL,
+                gf_msg ("glusterd", GF_LOG_CRITICAL, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "Unable to create "GEOREP" log directory");
                 goto out;
         }
@@ -518,7 +533,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf)
         /* Slave log file directory */
         if (strlen(DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"-slaves") >= PATH_MAX) {
                 ret = -1;
-                gf_log ("glusterd", GF_LOG_CRITICAL,
+                gf_msg ("glusterd", GF_LOG_CRITICAL, 0,
+                        GD_MSG_DIRPATH_TOO_LONG,
                         "directory path "DEFAULT_LOG_FILE_DIRECTORY"/"
                         GEOREP"-slaves"" is longer than PATH_MAX");
                 goto out;
@@ -526,7 +542,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf)
         ret = mkdir_p (DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"-slaves", 0777,
                       _gf_true);
         if (-1 == ret) {
-                gf_log ("glusterd", GF_LOG_CRITICAL,
+                gf_msg ("glusterd", GF_LOG_CRITICAL, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "Unable to create "GEOREP" slave log directory");
                 goto out;
         }
@@ -534,7 +551,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf)
         /* MountBroker log file directory */
         if (strlen(DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"-slaves/mbr") >= PATH_MAX) {
                 ret = -1;
-                gf_log ("glusterd", GF_LOG_CRITICAL,
+                gf_msg ("glusterd", GF_LOG_CRITICAL, 0,
+                        GD_MSG_DIRPATH_TOO_LONG,
                         "directory path "DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP
                         "-slaves/mbr"" is longer than PATH_MAX");
                 goto out;
@@ -542,7 +560,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf)
         ret = mkdir_p (DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"-slaves/mbr", 0777,
                       _gf_true);
         if (-1 == ret) {
-                gf_log ("glusterd", GF_LOG_CRITICAL,
+                gf_msg ("glusterd", GF_LOG_CRITICAL, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "Unable to create "GEOREP" mountbroker slave log directory");
                 goto out;
         }
@@ -553,7 +572,8 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf)
         else {
                 gr = getgrnam (greplg_s);
                 if (!gr) {
-                        gf_log ("glusterd", GF_LOG_CRITICAL,
+                        gf_msg ("glusterd", GF_LOG_CRITICAL, 0,
+                                GD_MSG_LOGGROUP_INVALID,
                                 "group "GEOREP"-log-group %s does not exist", greplg_s);
                         ret = -1;
                         goto out;
@@ -570,7 +590,7 @@ glusterd_crt_georep_folders (char *georepdir, glusterd_conf_t *conf)
         }
 
  out:
-        gf_log("", GF_LOG_DEBUG, "Returning %d", ret);
+        gf_msg_debug ("", 0, "Returning %d", ret);
         return ret;
 }
 
@@ -822,7 +842,8 @@ check_prepare_mountbroker_root (char *mountbroker_root)
                 ret = fstat (dfd, &st);
         }
         if (ret == -1 || !S_ISDIR (st.st_mode)) {
-                gf_log ("", GF_LOG_ERROR,
+                gf_msg ("", GF_LOG_ERROR, errno,
+                        GD_MSG_DIR_OP_FAILED,
                         "cannot access mountbroker-root directory %s",
                         mountbroker_root);
                 ret = -1;
@@ -830,14 +851,16 @@ check_prepare_mountbroker_root (char *mountbroker_root)
         }
         if (st.st_uid != 0 ||
             (st.st_mode & (S_IWGRP|S_IWOTH))) {
-                gf_log ("", GF_LOG_ERROR,
+                gf_msg ("", GF_LOG_ERROR, 0,
+                        GD_MSG_DIR_PERM_LIBERAL,
                         "permissions on mountbroker-root directory %s are "
                         "too liberal", mountbroker_root);
                 ret = -1;
                 goto out;
         }
         if (!(st.st_mode & (S_IXGRP|S_IXOTH))) {
-                gf_log ("", GF_LOG_WARNING,
+                gf_msg ("", GF_LOG_WARNING, 0,
+                        GD_MSG_DIR_PERM_STRICT,
                         "permissions on mountbroker-root directory %s are "
                         "probably too strict", mountbroker_root);
         }
@@ -851,7 +874,8 @@ check_prepare_mountbroker_root (char *mountbroker_root)
                         ret = fstat (dfd2, &st2);
                 }
                 if (ret == -1) {
-                        gf_log ("", GF_LOG_ERROR,
+                        gf_msg ("", GF_LOG_ERROR, errno,
+                                GD_MSG_DIR_OP_FAILED,
                                 "error while checking mountbroker-root ancestors "
                                 "%d (%s)", errno, strerror (errno));
                         goto out;
@@ -863,14 +887,16 @@ check_prepare_mountbroker_root (char *mountbroker_root)
                 if (st2.st_uid != 0 ||
                     ((st2.st_mode & (S_IWGRP|S_IWOTH)) &&
                      !(st2.st_mode & S_ISVTX))) {
-                        gf_log ("", GF_LOG_ERROR,
+                        gf_msg ("", GF_LOG_ERROR, 0,
+                                GD_MSG_DIR_PERM_LIBERAL,
                                 "permissions on ancestors of mountbroker-root "
                                 "directory are too liberal");
                         ret = -1;
                         goto out;
                 }
                 if (!(st.st_mode & (S_IXGRP|S_IXOTH))) {
-                        gf_log ("", GF_LOG_WARNING,
+                        gf_msg ("", GF_LOG_WARNING, 0,
+                                GD_MSG_DIR_PERM_STRICT,
                                 "permissions on ancestors of mountbroker-root "
                                 "directory are probably too strict");
                 }
@@ -886,7 +912,8 @@ check_prepare_mountbroker_root (char *mountbroker_root)
         if (ret != -1)
                 ret = sys_fstatat (dfd0, MB_HIVE, &st, AT_SYMLINK_NOFOLLOW);
         if (ret == -1 || st.st_mode != (S_IFDIR|0711)) {
-                gf_log ("", GF_LOG_ERROR,
+                gf_msg ("", GF_LOG_ERROR, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "failed to set up mountbroker-root directory %s",
                         mountbroker_root);
                 ret = -1;
@@ -977,7 +1004,8 @@ _install_mount_spec (dict_t *opts, char *key, data_t *value, void *data)
         return 0;
  err:
 
-        gf_log ("", GF_LOG_ERROR,
+        gf_msg ("", GF_LOG_ERROR, 0,
+                GD_MSG_MOUNT_SPEC_INSTALL_FAIL,
                 "adding %smount spec failed: label: %s desc: %s",
                 georep ? GEOREP" " : "", label, pdesc);
 
@@ -1042,14 +1070,14 @@ glusterd_init_uds_listener (xlator_t *this)
         ret = rpcsvc_register_notify (rpc, glusterd_uds_rpcsvc_notify,
                                       this);
         if (ret) {
-                gf_log (this->name, GF_LOG_DEBUG,
+                gf_msg_debug (this->name, 0,
                         "Failed to register notify function");
                 goto out;
         }
 
         ret = rpcsvc_create_listeners (rpc, options, this->name);
         if (ret != 1) {
-                gf_log (this->name, GF_LOG_DEBUG, "Failed to create listener");
+                gf_msg_debug (this->name, 0, "Failed to create listener");
                 goto out;
         }
         ret = 0;
@@ -1071,7 +1099,9 @@ out:
                 dict_unref (options);
 
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to start glusterd "
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_GLUSTERD_SOCK_LISTENER_START_FAIL,
+                        "Failed to start glusterd "
                         "unix domain socket listener.");
                 if (rpc) {
                         GF_FREE (rpc);
@@ -1165,7 +1195,8 @@ glusterd_find_correct_var_run_dir (xlator_t *this, char *var_run_dir)
          */
         ret = lstat (GLUSTERD_VAR_RUN_DIR, &buf);
         if (ret != 0) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_FILE_OP_FAILED,
                         "stat fails on %s, exiting. (errno = %d)",
                         GLUSTERD_VAR_RUN_DIR, errno);
                 goto out;
@@ -1200,7 +1231,8 @@ glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir,
 
         ret = stat (abs_path, &buf);
         if ((ret != 0) && (ENOENT != errno)) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_FILE_OP_FAILED,
                         "stat fails on %s, exiting. (errno = %d)",
                         abs_path, errno);
                 ret = -1;
@@ -1208,7 +1240,8 @@ glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir,
         }
 
         if ((!ret) && (!S_ISDIR(buf.st_mode))) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, ENOENT,
+                        GD_MSG_DIR_NOT_FOUND,
                         "Provided snap path %s is not a directory,"
                         "exiting", abs_path);
                 ret = -1;
@@ -1220,7 +1253,8 @@ glusterd_init_var_run_dirs (xlator_t *this, char *var_run_dir,
                 ret = mkdir_p (abs_path, 0777, _gf_true);
 
                 if (-1 == ret) {
-                        gf_log (this->name, GF_LOG_CRITICAL,
+                        gf_msg (this->name, GF_LOG_CRITICAL, errno,
+                                GD_MSG_CREATE_DIR_FAILED,
                                 "Unable to create directory %s"
                                 " ,errno = %d", abs_path, errno);
                         goto out;
@@ -1247,27 +1281,32 @@ glusterd_svc_init_all ()
         /* Init SHD svc */
         ret = glusterd_shdsvc_init (&(priv->shd_svc));
         if (ret) {
-                gf_log (THIS->name, GF_LOG_ERROR, "Failed to init shd service");
+                gf_msg (THIS->name, GF_LOG_ERROR, 0,
+                        GD_MSG_FAILED_INIT_SHDSVC,
+                        "Failed to init shd service");
                 goto out;
         }
-        gf_log (THIS->name, GF_LOG_DEBUG, "shd service initialized");
+        gf_msg_debug (THIS->name, 0, "shd service initialized");
 
         /* Init NFS svc */
         ret = glusterd_nfssvc_init (&(priv->nfs_svc));
         if (ret) {
-                gf_log (THIS->name, GF_LOG_ERROR, "Failed to init nfs service");
+                gf_msg (THIS->name, GF_LOG_ERROR, 0,
+                        GD_MSG_FAILED_INIT_NFSSVC,
+                        "Failed to init nfs service");
                 goto out;
         }
-        gf_log (THIS->name, GF_LOG_DEBUG, "nfs service initialized");
+        gf_msg_debug (THIS->name, 0, "nfs service initialized");
 
         /* Init QuotaD svc */
         ret = glusterd_quotadsvc_init (&(priv->quotad_svc));
         if (ret) {
-                gf_log (THIS->name, GF_LOG_ERROR, "Failed to init quotad "
+                gf_msg (THIS->name, GF_LOG_ERROR, 0,
+                        GD_MSG_FAILED_INIT_QUOTASVC, "Failed to init quotad "
                         "service");
                 goto out;
         }
-        gf_log (THIS->name, GF_LOG_DEBUG, "quotad service initialized");
+        gf_msg_debug (THIS->name, 0, "quotad service initialized");
 
         /* Init BitD svc */
         ret = glusterd_bitdsvc_init (&(priv->bitd_svc));
@@ -1323,7 +1362,8 @@ init (xlator_t *this)
                 lim.rlim_max = 65536;
 
                 if (setrlimit (RLIMIT_NOFILE, &lim) == -1) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, errno,
+                                GD_MSG_SETXATTR_FAIL,
                                 "Failed to set 'ulimit -n "
                                 " 65536': %s", strerror(errno));
                 } else {
@@ -1345,14 +1385,16 @@ init (xlator_t *this)
 
         ret = stat (workdir, &buf);
         if ((ret != 0) && (ENOENT != errno)) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, errno,
+                        GD_MSG_DIR_OP_FAILED,
                         "stat fails on %s, exiting. (errno = %d)",
                         workdir, errno);
                 exit (1);
         }
 
         if ((!ret) && (!S_ISDIR(buf.st_mode))) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, ENOENT,
+                        GD_MSG_DIR_NOT_FOUND,
                         "Provided working area %s is not a directory,"
                         "exiting", workdir);
                 exit (1);
@@ -1363,7 +1405,8 @@ init (xlator_t *this)
                 ret = mkdir_p (workdir, 0777, _gf_true);
 
                 if (-1 == ret) {
-                        gf_log (this->name, GF_LOG_CRITICAL,
+                        gf_msg (this->name, GF_LOG_CRITICAL, errno,
+                                GD_MSG_CREATE_DIR_FAILED,
                                 "Unable to create directory %s"
                                 " ,errno = %d", workdir, errno);
                         exit (1);
@@ -1386,8 +1429,9 @@ init (xlator_t *this)
         ret = glusterd_init_var_run_dirs (this, var_run_dir,
                                       GLUSTERD_DEFAULT_SNAPS_BRICK_DIR);
         if (ret) {
-                gf_log (this->name, GF_LOG_CRITICAL, "Unable to create "
-                        "snap backend dir");
+                gf_msg (this->name, GF_LOG_CRITICAL, 0,
+                        GD_MSG_CREATE_DIR_FAILED, "Unable to create "
+                        "snap backend folder");
                 exit (1);
         }
 
@@ -1410,7 +1454,8 @@ init (xlator_t *this)
         ret = gf_cmd_log_init (cmd_log_filename);
 
         if (ret == -1) {
-                gf_log ("this->name", GF_LOG_CRITICAL,
+                gf_msg ("this->name", GF_LOG_CRITICAL, errno,
+                        GD_MSG_FILE_OP_FAILED,
                         "Unable to create cmd log file %s", cmd_log_filename);
                 exit (1);
         }
@@ -1420,7 +1465,8 @@ init (xlator_t *this)
         ret = mkdir (storedir, 0777);
 
         if ((-1 == ret) && (errno != EEXIST)) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "Unable to create volume directory %s"
                         " ,errno = %d", storedir, errno);
                 exit (1);
@@ -1431,7 +1477,8 @@ init (xlator_t *this)
         ret = mkdir (storedir, 0777);
 
         if ((-1 == ret) && (errno != EEXIST)) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "Unable to create snaps directory %s"
                         " ,errno = %d", storedir, errno);
                 exit (1);
@@ -1442,7 +1489,8 @@ init (xlator_t *this)
         ret = mkdir (storedir, 0777);
 
         if ((-1 == ret) && (errno != EEXIST)) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "Unable to create peers directory %s"
                         " ,errno = %d", storedir, errno);
                 exit (1);
@@ -1451,7 +1499,8 @@ init (xlator_t *this)
         snprintf (storedir, PATH_MAX, "%s/bricks", DEFAULT_LOG_FILE_DIRECTORY);
         ret = mkdir (storedir, 0777);
         if ((-1 == ret) && (errno != EEXIST)) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "Unable to create logs directory %s"
                         " ,errno = %d", storedir, errno);
                 exit (1);
@@ -1460,7 +1509,8 @@ init (xlator_t *this)
         snprintf (storedir, PATH_MAX, "%s/nfs", workdir);
         ret = mkdir (storedir, 0777);
         if ((-1 == ret) && (errno != EEXIST)) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "Unable to create nfs directory %s"
                         " ,errno = %d", storedir, errno);
                 exit (1);
@@ -1487,7 +1537,8 @@ init (xlator_t *this)
         snprintf (storedir, PATH_MAX, "%s/glustershd", workdir);
         ret = mkdir (storedir, 0777);
         if ((-1 == ret) && (errno != EEXIST)) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "Unable to create glustershd directory %s"
                         " ,errno = %d", storedir, errno);
                 exit (1);
@@ -1496,7 +1547,8 @@ init (xlator_t *this)
         snprintf (storedir, PATH_MAX, "%s/quotad", workdir);
         ret = mkdir (storedir, 0777);
         if ((-1 == ret) && (errno != EEXIST)) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "Unable to create quotad directory %s"
                         " ,errno = %d", storedir, errno);
                 exit (1);
@@ -1505,7 +1557,8 @@ init (xlator_t *this)
         snprintf (storedir, PATH_MAX, "%s/groups", workdir);
         ret = mkdir (storedir, 0777);
         if ((-1 == ret) && (errno != EEXIST)) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, errno,
+                        GD_MSG_CREATE_DIR_FAILED,
                         "Unable to create glustershd directory %s"
                         " ,errno = %d", storedir, errno);
                 exit (1);
@@ -1516,14 +1569,16 @@ init (xlator_t *this)
                 goto out;
         rpc = rpcsvc_init (this, this->ctx, this->options, 64);
         if (rpc == NULL) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_RPC_INIT_FAIL,
                         "failed to init rpc");
                 goto out;
         }
 
         ret = rpcsvc_register_notify (rpc, glusterd_rpcsvc_notify, this);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_RPCSVC_REG_NOTIFY_RETURNED,
                         "rpcsvc_register_notify returned %d", ret);
                 goto out;
         }
@@ -1538,7 +1593,8 @@ init (xlator_t *this)
                 ret = dict_set_str (this->options,
                                     "transport.socket.own-thread", "off");
                 if (ret != 0) {
-                        gf_log (this->name, GF_LOG_ERROR,
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
+                                GD_MSG_DICT_SET_FAILED,
                                 "failed to clear own-thread");
                         goto out;
                 }
@@ -1561,14 +1617,16 @@ init (xlator_t *this)
 
         ret = dict_get_str (this->options, "transport-type", &transport_type);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR, "Failed to get transport type");
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_DICT_GET_FAILED, "Failed to get transport type");
                 ret = -1;
                 goto out;
         }
 
         total_transport = rpc_transport_count (transport_type);
         if (total_transport <= 0) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_RPC_TRANSPORT_COUNT_GET_FAIL,
                         "failed to get total number of available tranpsorts");
                 ret = -1;
                 goto out;
@@ -1576,12 +1634,14 @@ init (xlator_t *this)
 
         ret = rpcsvc_create_listeners (rpc, this->options, this->name);
         if (ret < 1) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_RPC_LISTENER_CREATE_FAIL,
                         "creation of listener failed");
                 ret = -1;
                 goto out;
         } else if (ret < total_transport) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_RPC_LISTENER_CREATE_FAIL,
                         "creation of %d listeners failed, continuing with "
                         "succeeded transport", (total_transport - ret));
         }
@@ -1641,20 +1701,22 @@ init (xlator_t *this)
 
          conf->base_port = GF_IANA_PRIV_PORTS_START;
          if (dict_get_uint32(this->options, "base-port", &conf->base_port) == 0) {
-                 gf_log (this->name, GF_LOG_INFO,
-                         "base-port override: %d", conf->base_port);
+                gf_msg (this->name, GF_LOG_INFO, 0,
+                        GD_MSG_DICT_SET_FAILED,
+                        "base-port override: %d", conf->base_port);
          }
 
         /* Set option to run bricks on valgrind if enabled in glusterd.vol */
         conf->valgrind = _gf_false;
         ret = dict_get_str (this->options, "run-with-valgrind", &valgrind_str);
         if (ret < 0) {
-                gf_log (this->name, GF_LOG_DEBUG,
+                gf_msg_debug (this->name, 0,
                         "cannot get run-with-valgrind value");
         }
         if (valgrind_str) {
                 if (gf_string2boolean (valgrind_str, &(conf->valgrind))) {
-                        gf_log (this->name, GF_LOG_WARNING,
+                        gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+                                GD_MSG_INVALID_ENTRY,
                                 "run-with-valgrind value not a boolean string");
                 }
         }
@@ -1675,7 +1737,8 @@ init (xlator_t *this)
          */
         ret = glusterd_hooks_create_hooks_directory (conf->workdir);
         if (-1 == ret) {
-                gf_log (this->name, GF_LOG_CRITICAL,
+                gf_msg (this->name, GF_LOG_CRITICAL, errno,
+                        GD_MSG_DIR_OP_FAILED,
                         "Unable to create hooks directory ");
                 exit (1);
         }
@@ -1709,7 +1772,8 @@ init (xlator_t *this)
          * */
         ret = glusterd_restore_op_version (this);
         if (ret) {
-                gf_log (this->name, GF_LOG_ERROR,
+                gf_msg (this->name, GF_LOG_ERROR, 0,
+                        GD_MSG_OP_VERS_RESTORE_FAIL,
                         "Failed to restore op_version");
                 goto out;
         }
-- 
1.7.1