Blob Blame History Raw
From 5fb84aeaca956f8b09605491c067a521f2f0942f Mon Sep 17 00:00:00 2001
From: Mohamed Ashiq <ashiq333@gmail.com>
Date: Tue, 19 May 2015 15:11:45 +0530
Subject: [PATCH 166/190] graph/libglusterfs : porting to a new logging framework

Change-Id: I57ed5c979c15559443712a61f0b1a61c7f5557d8
BUG: 1231792
Signed-off-by: Mohamed Ashiq Liyazudeen <mliyazud@redhat.com>
Reviewed-on: http://review.gluster.org/10822
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/51692
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Tested-by: Venky Shankar <vshankar@redhat.com>
---
 libglusterfs/src/graph-print.c |   16 +++---
 libglusterfs/src/graph.c       |  108 +++++++++++++++++++++-----------------
 libglusterfs/src/graph.l       |    2 -
 libglusterfs/src/graph.y       |  113 +++++++++++++++++++---------------------
 4 files changed, 124 insertions(+), 115 deletions(-)

diff --git a/libglusterfs/src/graph-print.c b/libglusterfs/src/graph-print.c
index d860d63..7842093 100644
--- a/libglusterfs/src/graph-print.c
+++ b/libglusterfs/src/graph-print.c
@@ -18,7 +18,7 @@
 #include "common-utils.h"
 #include "xlator.h"
 #include "graph-utils.h"
-
+#include "libglusterfs-messages.h"
 
 
 struct gf_printer {
@@ -33,8 +33,8 @@ gp_write_file (struct gf_printer *gp, char *buf, size_t len)
         FILE *f = gp->priv;
 
         if (fwrite (buf, len, 1, f) != 1) {
-                gf_log ("graph-print", GF_LOG_ERROR, "fwrite failed (%s)",
-                        strerror (errno));
+                gf_msg ("graph-print", GF_LOG_ERROR, errno,
+                        LG_MSG_FWRITE_FAILED, "fwrite failed");
 
                 return -1;
         }
@@ -48,7 +48,8 @@ gp_write_buf (struct gf_printer *gp, char *buf, size_t len)
         struct iovec *iov = gp->priv;
 
         if (iov->iov_len < len) {
-                gf_log ("graph-print", GF_LOG_ERROR, "buffer full");
+                gf_msg ("graph-print", GF_LOG_ERROR, 0, LG_MSG_BUFFER_FULL,
+                        "buffer full");
 
                 return -1;
         }
@@ -139,7 +140,8 @@ glusterfs_graph_print (struct gf_printer *gp, glusterfs_graph_t *graph)
 out:
         len = gp->len;
         if (ret == -1) {
-                gf_log ("graph-print", GF_LOG_ERROR, "printing failed");
+                gf_msg ("graph-print", GF_LOG_ERROR, 0, LG_MSG_PRINT_FAILED,
+                        "printing failed");
 
                 return -1;
         }
@@ -172,8 +174,8 @@ glusterfs_graph_print_buf (glusterfs_graph_t *graph)
 
         f = fopen ("/dev/null", "a");
         if (!f) {
-                gf_log ("graph-print", GF_LOG_ERROR,
-                        "cannot open /dev/null (%s)", strerror (errno));
+                gf_msg ("graph-print", GF_LOG_ERROR, errno,
+                        LG_MSG_DIR_OP_FAILED, "cannot open /dev/null");
 
                 return NULL;
         }
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
index 709ec3b..3f6e399 100644
--- a/libglusterfs/src/graph.c
+++ b/libglusterfs/src/graph.c
@@ -19,6 +19,7 @@
 #include <fnmatch.h>
 #include "defaults.h"
 
+#include "libglusterfs-messages.h"
 
 #if 0
 static void
@@ -123,7 +124,7 @@ glusterfs_graph_insert (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx,
         xlator_t        *ixl = NULL;
 
         if (!ctx->master) {
-                gf_log ("glusterfs", GF_LOG_ERROR,
+                gf_msg ("glusterfs", GF_LOG_ERROR, 0, LG_MSG_VOLUME_ERROR,
                         "volume \"%s\" can be added from command line only "
                         "on client side", type);
 
@@ -147,7 +148,7 @@ glusterfs_graph_insert (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx,
         ixl->is_autoloaded = autoload;
 
         if (xlator_set_type (ixl, type) == -1) {
-                gf_log ("glusterfs", GF_LOG_ERROR,
+                gf_msg ("glusterfs", GF_LOG_ERROR, 0, LG_MSG_INIT_FAILED,
                         "%s (%s) initialization failed",
                         name, type);
                 return -1;
@@ -262,17 +263,18 @@ gf_add_cmdline_options (glusterfs_graph_t *graph, cmd_args_t *cmd_args)
                                                     cmd_option->key,
                                                     cmd_option->value);
                                 if (ret == 0) {
-                                        gf_log (trav->name, GF_LOG_INFO,
+                                        gf_msg (trav->name, GF_LOG_INFO, 0,
+                                                LG_MSG_VOL_OPTION_ADD,
                                                 "adding option '%s' for "
                                                 "volume '%s' with value '%s'",
                                                 cmd_option->key, trav->name,
                                                 cmd_option->value);
                                 } else {
-                                        gf_log (trav->name, GF_LOG_WARNING,
+                                        gf_msg (trav->name, GF_LOG_WARNING,
+                                                -ret, LG_MSG_VOL_OPTION_ADD,
                                                 "adding option '%s' for "
-                                                "volume '%s' failed: %s",
-                                                cmd_option->key, trav->name,
-                                                strerror (-ret));
+                                                "volume '%s' failed",
+                                                cmd_option->key, trav->name);
                                 }
                         }
                 }
@@ -296,8 +298,9 @@ glusterfs_graph_validate_options (glusterfs_graph_t *graph)
 
                 ret = xlator_options_validate (trav, trav->options, &errstr);
                 if (ret) {
-                        gf_log (trav->name, GF_LOG_ERROR,
-                                "validation failed: %s", errstr);
+                        gf_msg (trav->name, GF_LOG_ERROR, 0,
+                                LG_MSG_VALIDATION_FAILED, "validation failed: "
+                                "%s", errstr);
                         return ret;
                 }
                 trav = trav->next;
@@ -318,7 +321,8 @@ glusterfs_graph_init (glusterfs_graph_t *graph)
         while (trav) {
                 ret = xlator_init (trav);
                 if (ret) {
-                        gf_log (trav->name, GF_LOG_ERROR,
+                        gf_msg (trav->name, GF_LOG_ERROR, 0,
+                                LG_MSG_TRANSLATOR_INIT_FAILED,
                                 "initializing translator failed");
                         return ret;
                 }
@@ -353,7 +357,8 @@ _log_if_unknown_option (dict_t *dict, char *key, data_t *value, void *data)
         found = xlator_volume_option_get (xl, key);
 
         if (!found) {
-                gf_log (xl->name, GF_LOG_WARNING,
+                gf_msg (xl->name, GF_LOG_WARNING, 0,
+                        LG_MSG_XLATOR_OPTION_INVALID,
                         "option '%s' is not recognized", key);
         }
 
@@ -384,15 +389,15 @@ fill_uuid (char *uuid, int size)
         char           now_str[64];
 
         if (gettimeofday (&tv, NULL) == -1) {
-                gf_log ("graph", GF_LOG_ERROR,
-                        "gettimeofday: failed %s",
-                        strerror (errno));
+                gf_msg ("graph", GF_LOG_ERROR, errno,
+                        LG_MSG_GETTIMEOFDAY_FAILED, "gettimeofday: "
+                        "failed");
         }
 
         if (gethostname (hostname, 256) == -1) {
-                gf_log ("graph", GF_LOG_ERROR,
-                        "gethostname: failed %s",
-                        strerror (errno));
+                gf_msg ("graph", GF_LOG_ERROR, errno,
+                        LG_MSG_GETHOSTNAME_FAILED, "gethostname: "
+                        "failed");
         }
 
         gf_time_fmt (now_str, sizeof now_str, tv.tv_sec, gf_timefmt_dirent);
@@ -461,33 +466,37 @@ glusterfs_graph_prepare (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
         /* XXX: attach to -n volname */
         ret = glusterfs_graph_settop (graph, ctx);
         if (ret) {
-                gf_log ("graph", GF_LOG_ERROR, "glusterfs graph settop failed");
+                gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR,
+                        "glusterfs graph settop failed");
                 return -1;
         }
 
         /* XXX: WORM VOLUME */
         ret = glusterfs_graph_worm (graph, ctx);
         if (ret) {
-                gf_log ("graph", GF_LOG_ERROR, "glusterfs graph worm failed");
+                gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR,
+                        "glusterfs graph worm failed");
                 return -1;
         }
         ret = glusterfs_graph_acl (graph, ctx);
         if (ret) {
-                gf_log ("graph", GF_LOG_ERROR, "glusterfs graph ACL failed");
+                gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR,
+                        "glusterfs graph ACL failed");
                 return -1;
         }
 
         /* XXX: MAC COMPAT */
         ret = glusterfs_graph_mac_compat (graph, ctx);
         if (ret) {
-                gf_log ("graph", GF_LOG_ERROR, "glusterfs graph mac compat failed");
+                gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR,
+                        "glusterfs graph mac compat failed");
                 return -1;
         }
 
         /* XXX: gfid-access */
         ret = glusterfs_graph_gfid_access (graph, ctx);
         if (ret) {
-                gf_log ("graph", GF_LOG_ERROR,
+                gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR,
                         "glusterfs graph 'gfid-access' failed");
                 return -1;
         }
@@ -495,7 +504,7 @@ glusterfs_graph_prepare (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
 	/* XXX: topmost xlator */
 	ret = glusterfs_graph_meta (graph, ctx);
 	if (ret) {
-		gf_log ("graph", GF_LOG_ERROR,
+		gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR,
 			"glusterfs graph meta failed");
 		return -1;
 	}
@@ -651,20 +660,24 @@ glusterfs_graph_activate (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
         /* XXX: all xlator options validation */
         ret = glusterfs_graph_validate_options (graph);
         if (ret) {
-                gf_log ("graph", GF_LOG_ERROR, "validate options failed");
+                gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_VALIDATION_FAILED,
+                        "validate options failed");
                 return ret;
         }
 
         /* XXX: perform init () */
         ret = glusterfs_graph_init (graph);
         if (ret) {
-                gf_log ("graph", GF_LOG_ERROR, "init failed");
+                gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_INIT_FAILED,
+                        "init failed");
                 return ret;
         }
 
         ret = glusterfs_graph_unknown_options (graph);
         if (ret) {
-                gf_log ("graph", GF_LOG_ERROR, "unknown options failed");
+                gf_msg ("graph", GF_LOG_ERROR, 0,
+                        LG_MSG_UNKNOWN_OPTIONS_FAILED, "unknown options "
+                        "failed");
                 return ret;
         }
 
@@ -677,7 +690,8 @@ glusterfs_graph_activate (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
         if (ctx->master) {
                 ret = xlator_notify (ctx->master, GF_EVENT_GRAPH_NEW, graph);
                 if (ret) {
-                        gf_log ("graph", GF_LOG_ERROR,
+                        gf_msg ("graph", GF_LOG_ERROR, 0,
+                                LG_MSG_EVENT_NOTIFY_FAILED,
                                 "graph new notification failed");
                         return ret;
                 }
@@ -687,7 +701,8 @@ glusterfs_graph_activate (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx)
         /* XXX: perform parent up */
         ret = glusterfs_graph_parent_up (graph);
         if (ret) {
-                gf_log ("graph", GF_LOG_ERROR, "parent up notification failed");
+                gf_msg ("graph", GF_LOG_ERROR, 0, LG_MSG_EVENT_NOTIFY_FAILED,
+                        "parent up notification failed");
                 return ret;
         }
 
@@ -703,7 +718,7 @@ xlator_equal_rec (xlator_t *xl1, xlator_t *xl2)
         int            ret   = 0;
 
         if (xl1 == NULL || xl2 == NULL) {
-                gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
+                gf_msg_debug ("xlator", 0, "invalid argument");
                 return -1;
         }
 
@@ -713,8 +728,8 @@ xlator_equal_rec (xlator_t *xl1, xlator_t *xl2)
         while (trav1 && trav2) {
                 ret = xlator_equal_rec (trav1->xlator, trav2->xlator);
                 if (ret) {
-                        gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG,
-                                "xlators children not equal");
+                        gf_msg_debug ("glusterfsd-mgmt", 0, "xlators children "
+                                      "not equal");
                         goto out;
                 }
 
@@ -758,15 +773,13 @@ is_graph_topology_equal (glusterfs_graph_t *graph1, glusterfs_graph_t *graph2)
         ret = xlator_equal_rec (trav1, trav2);
 
         if (ret) {
-                gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG,
-                        "graphs are not equal");
+                gf_msg_debug ("glusterfsd-mgmt", 0, "graphs are not equal");
                 ret = _gf_false;
                 goto out;
         }
 
         ret = _gf_true;
-        gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG,
-                "graphs are equal");
+        gf_msg_debug ("glusterfsd-mgmt", 0, "graphs are equal");
 
 out:
         return ret;
@@ -795,7 +808,7 @@ glusterfs_volfile_reconfigure (int oldvollen, FILE *newvolfile_fp,
         }
 
         if (!ctx) {
-                gf_log ("glusterfsd-mgmt", GF_LOG_ERROR,
+                gf_msg ("glusterfsd-mgmt", GF_LOG_ERROR, 0, LG_MSG_CTX_NULL,
 			"ctx is NULL");
 		goto out;
 	}
@@ -803,17 +816,19 @@ glusterfs_volfile_reconfigure (int oldvollen, FILE *newvolfile_fp,
         oldvolfile_graph = ctx->active;
         if (!oldvolfile_graph) {
                 active_graph_found = _gf_false;
-                gf_log ("glusterfsd-mgmt", GF_LOG_ERROR,
+                gf_msg ("glusterfsd-mgmt", GF_LOG_ERROR, 0,
+                        LG_MSG_ACTIVE_GRAPH_NULL,
                         "glusterfs_ctx->active is NULL");
 
                 oldvolfile_fp = tmpfile ();
                 if (!oldvolfile_fp) {
-                        gf_log ("glusterfsd-mgmt", GF_LOG_ERROR, "Unable to "
-                                "create temporary volfile: (%s)",
-                                strerror (errno));
+                        gf_msg ("glusterfsd-mgmt", GF_LOG_ERROR, errno,
+                                LG_MSG_TMPFILE_CREATE_FAILED, "Unable to "
+                                "create temporary volfile");
                         goto out;
                 }
 
+
                 fwrite (oldvolfile, oldvollen, 1, oldvolfile_fp);
                 fflush (oldvolfile_fp);
                 if (ferror (oldvolfile_fp)) {
@@ -836,21 +851,20 @@ glusterfs_volfile_reconfigure (int oldvollen, FILE *newvolfile_fp,
                                       newvolfile_graph)) {
 
                 ret = 1;
-                gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG,
-                        "Graph topology not equal(should call INIT)");
+                gf_msg_debug ("glusterfsd-mgmt", 0, "Graph topology not "
+                              "equal(should call INIT)");
                 goto out;
         }
 
-        gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG,
-                "Only options have changed in the new "
-                "graph");
+        gf_msg_debug ("glusterfsd-mgmt", 0, "Only options have changed in the"
+                      " new graph");
 
         /* */
         ret = glusterfs_graph_reconfigure (oldvolfile_graph,
                                            newvolfile_graph);
         if (ret) {
-                gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG,
-                        "Could not reconfigure new options in old graph");
+                gf_msg_debug ("glusterfsd-mgmt", 0, "Could not reconfigure "
+                              "new options in old graph");
                 goto out;
         }
 
diff --git a/libglusterfs/src/graph.l b/libglusterfs/src/graph.l
index e4eba9c..8af28a4 100644
--- a/libglusterfs/src/graph.l
+++ b/libglusterfs/src/graph.l
@@ -36,8 +36,6 @@ void append_string(const char *str, int size)
                         text = GF_REALLOC (text, new_size);
                 }
                 if (!text) {
-                        gf_log ("parser", GF_LOG_ERROR,
-                                "out of memory");
                         return;
                 }
 		text_asize = new_size;
diff --git a/libglusterfs/src/graph.y b/libglusterfs/src/graph.y
index 42d638e..9fd0282 100644
--- a/libglusterfs/src/graph.y
+++ b/libglusterfs/src/graph.y
@@ -25,6 +25,7 @@
 #include "xlator.h"
 #include "graph-utils.h"
 #include "logging.h"
+#include "libglusterfs-messages.h"
 
 static int new_volume (char *name);
 static int volume_type (char *type);
@@ -81,7 +82,7 @@ type_error (void)
 {
         extern int graphyylineno;
 
-        gf_log ("parser", GF_LOG_ERROR,
+        gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_VOLFILE_PARSE_ERROR,
                 "Volume %s, before line %d: Please specify volume type",
                 curr->name, graphyylineno);
         return;
@@ -93,7 +94,7 @@ sub_error (void)
 {
         extern int graphyylineno;
 
-        gf_log ("parser", GF_LOG_ERROR,
+        gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_VOLFILE_PARSE_ERROR,
                 "Volume %s, before line %d: Please specify subvolumes",
                 curr->name, graphyylineno);
         return;
@@ -105,7 +106,7 @@ option_error (void)
 {
         extern int graphyylineno;
 
-        gf_log ("parser", GF_LOG_ERROR,
+        gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_VOLFILE_PARSE_ERROR,
                 "Volume %s, before line %d: Please specify "
                 "option <key> <value>",
                 curr->name, graphyylineno);
@@ -121,14 +122,13 @@ new_volume (char *name)
         int          ret = 0;
 
         if (!name) {
-                gf_log ("parser", GF_LOG_DEBUG,
-			"Invalid argument name: '%s'", name);
+                gf_msg_debug ("parser", 0,"Invalid argument name: '%s'", name);
                 ret = -1;
                 goto out;
         }
 
         if (curr) {
-                gf_log ("parser", GF_LOG_ERROR,
+                gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY,
                         "new volume (%s) definition in line %d unexpected",
                         name, graphyylineno);
                 ret = -1;
@@ -139,7 +139,6 @@ new_volume (char *name)
                                    gf_common_mt_xlator_t);
 
         if (!curr) {
-                gf_log ("parser", GF_LOG_ERROR, "Out of memory");
                 ret = -1;
                 goto out;
         }
@@ -148,9 +147,9 @@ new_volume (char *name)
 
         while (trav) {
                 if (!strcmp (name, trav->name)) {
-                        gf_log ("parser", GF_LOG_ERROR,
-				"Line %d: volume '%s' defined again",
-                                graphyylineno, name);
+                        gf_msg ("parser", GF_LOG_ERROR, 0,
+                                LG_MSG_VOLFILE_PARSE_ERROR, "Line %d: volume "
+                                "'%s' defined again", graphyylineno, name);
                         ret = -1;
                         goto out;
                 }
@@ -183,7 +182,7 @@ new_volume (char *name)
 
         construct->xl_count++;
 
-        gf_log ("parser", GF_LOG_TRACE, "New node for '%s'", name);
+        gf_msg_trace ("parser", 0, "New node for '%s'", name);
 
 out:
         GF_FREE (name);
@@ -199,14 +198,14 @@ volume_type (char *type)
         int32_t      ret = 0;
 
         if (!type) {
-                gf_log ("parser", GF_LOG_DEBUG, "Invalid argument type");
+                gf_msg_debug ("parser", 0, "Invalid argument type");
                 ret = -1;
                 goto out;
         }
 
         ret = xlator_set_type (curr, type);
         if (ret) {
-                gf_log ("parser", GF_LOG_ERROR,
+                gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY,
                         "Volume '%s', line %d: type '%s' is not valid or "
 			"not found on this machine",
                         curr->name, graphyylineno, type);
@@ -214,7 +213,7 @@ volume_type (char *type)
                 goto out;
         }
 
-        gf_log ("parser", GF_LOG_TRACE, "Type:%s:%s", curr->name, type);
+        gf_msg_trace ("parser", 0, "Type:%s:%s", curr->name, type);
 
 out:
         GF_FREE (type);
@@ -231,7 +230,8 @@ volume_option (char *key, char *value)
         char       *set_value = NULL;
 
         if (!key || !value){
-                gf_log ("parser", GF_LOG_ERROR, "Invalid argument");
+                gf_msg ("parser", GF_LOG_ERROR, 0,
+                        LG_MSG_INVALID_VOLFILE_ENTRY, "Invalid argument");
                 ret = -1;
                 goto out;
         }
@@ -240,16 +240,15 @@ volume_option (char *key, char *value)
 	ret = dict_set_dynstr (curr->options, key, set_value);
 
         if (ret == 1) {
-                gf_log ("parser", GF_LOG_ERROR,
-                        "Volume '%s', line %d: duplicate entry "
-			"('option %s') present",
+                gf_msg ("parser", GF_LOG_ERROR, 0,
+                        LG_MSG_INVALID_VOLFILE_ENTRY, "Volume '%s', line %d: "
+                        "duplicate entry ('option %s') present",
                         curr->name, graphyylineno, key);
                 ret = -1;
                 goto out;
         }
 
-        gf_log ("parser", GF_LOG_TRACE, "Option:%s:%s:%s",
-                curr->name, key, value);
+        gf_msg_trace ("parser", 0, "Option:%s:%s:%s", curr->name, key, value);
 
 out:
         GF_FREE (key);
@@ -267,7 +266,8 @@ volume_sub (char *sub)
         int              ret = 0;
 
         if (!sub) {
-                gf_log ("parser", GF_LOG_ERROR, "Invalid subvolumes argument");
+                gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY,
+                        "Invalid subvolumes argument");
                 ret = -1;
                 goto out;
         }
@@ -281,16 +281,15 @@ volume_sub (char *sub)
         }
 
         if (!trav) {
-                gf_log ("parser", GF_LOG_ERROR,
+                gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_SUB_VOLUME_ERROR,
                         "Volume '%s', line %d: subvolume '%s' is not defined "
-			"prior to usage",
-                        curr->name, graphyylineno, sub);
+			"prior to usage",curr->name, graphyylineno, sub);
                 ret = -1;
                 goto out;
         }
 
         if (trav == curr) {
-                gf_log ("parser", GF_LOG_ERROR,
+                gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY,
                         "Volume '%s', line %d: has '%s' itself as subvolume",
                         curr->name, graphyylineno, sub);
                 ret = -1;
@@ -299,12 +298,11 @@ volume_sub (char *sub)
 
 	ret = glusterfs_xlator_link (curr, trav);
 	if (ret) {
-                gf_log ("parser", GF_LOG_ERROR, "Out of memory");
                 ret = -1;
                 goto out;
         }
 
-        gf_log ("parser", GF_LOG_TRACE, "child:%s->%s", curr->name, sub);
+        gf_msg_trace ("parser", 0, "child:%s->%s", curr->name, sub);
 
 out:
         GF_FREE (sub);
@@ -317,11 +315,11 @@ static int
 volume_end (void)
 {
         if (!curr->fops) {
-                gf_log ("parser", GF_LOG_ERROR,
+                gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_VOLUME_ERROR,
                         "\"type\" not specified for volume %s", curr->name);
                 return -1;
         }
-        gf_log ("parser", GF_LOG_TRACE, "end:%s", curr->name);
+        gf_msg_trace ("parser", 0, "end:%s", curr->name);
 
         curr = NULL;
         return 0;
@@ -343,38 +341,35 @@ graphyyerror (const char *str)
 
         if (curr && curr->name && graphyytext) {
                 if (!strcmp (graphyytext, "volume")) {
-                        gf_log ("parser", GF_LOG_ERROR,
-                                "'end-volume' not defined for volume '%s'",
-				curr->name);
+                        gf_msg ("parser", GF_LOG_ERROR, 0,
+                                LG_MSG_VOLUME_ERROR, "'end-volume' not"
+                                " defined for volume '%s'", curr->name);
                 } else if (!strcmp (graphyytext, "type")) {
-                        gf_log ("parser", GF_LOG_ERROR,
+                        gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_VOLUME_ERROR,
                                 "line %d: duplicate 'type' defined for "
-				"volume '%s'",
-                                graphyylineno, curr->name);
+				"volume '%s'", graphyylineno, curr->name);
                 } else if (!strcmp (graphyytext, "subvolumes")) {
-                        gf_log ("parser", GF_LOG_ERROR,
-                                "line %d: duplicate 'subvolumes' defined for "
-				"volume '%s'",
+                        gf_msg ("parser", GF_LOG_ERROR, 0,
+                                LG_MSG_SUB_VOLUME_ERROR, "line %d: duplicate "
+                                "'subvolumes' defined for volume '%s'",
                                 graphyylineno, curr->name);
                 } else if (curr) {
-                        gf_log ("parser", GF_LOG_ERROR,
+                        gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_SYNTAX_ERROR,
                                 "syntax error: line %d (volume '%s'): \"%s\""
 				"\nallowed tokens are 'volume', 'type', "
 				"'subvolumes', 'option', 'end-volume'()",
-                                graphyylineno, curr->name,
-				graphyytext);
+                                graphyylineno, curr->name, graphyytext);
                 } else {
-                        gf_log ("parser", GF_LOG_ERROR,
+                        gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_SYNTAX_ERROR,
                                 "syntax error: line %d (just after volume "
 				"'%s'): \"%s\"\n(%s)",
-                                graphyylineno, curr->name,
-				graphyytext,
+                                graphyylineno, curr->name, graphyytext,
                                 "allowed tokens are 'volume', 'type', "
 				"'subvolumes', 'option', 'end-volume'");
                 }
         } else {
-                gf_log ("parser", GF_LOG_ERROR,
-                        "syntax error in line %d: \"%s\" \n"
+                gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_SYNTAX_ERROR,
+                        "syntax error in line %d: \"%s\"\n"
                         "(allowed tokens are 'volume', 'type', "
 			"'subvolumes', 'option', 'end-volume')\n",
                         graphyylineno, graphyytext);
@@ -395,7 +390,8 @@ execute_cmd (char *cmd, char **result, size_t size)
 
 	fpp = popen (cmd, "r");
 	if (!fpp) {
-		gf_log ("parser", GF_LOG_ERROR, "%s: failed to popen", cmd);
+		gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_FILE_OP_FAILED,
+                        "%s: failed to popen", cmd);
 		return -1;
 	}
 
@@ -445,7 +441,6 @@ preprocess (FILE *srcfp, FILE *dstfp)
 	cmd = GF_CALLOC (cmd_buf_size, 1,
                          gf_common_mt_char);
         if (cmd == NULL) {
-                gf_log ("parser", GF_LOG_ERROR, "Out of memory");
                 return -1;
         }
 
@@ -453,7 +448,6 @@ preprocess (FILE *srcfp, FILE *dstfp)
                             gf_common_mt_char);
         if (result == NULL) {
                 GF_FREE (cmd);
-                gf_log ("parser", GF_LOG_ERROR, "Out of memory");
                 return -1;
         }
 
@@ -515,9 +509,9 @@ preprocess (FILE *srcfp, FILE *dstfp)
         }
 
 	if (in_backtick) {
-		gf_log ("parser", GF_LOG_ERROR,
-			"Unterminated backtick in volume specfication file at line (%d), column (%d).",
-			line, column);
+		gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_VOLUME_ERROR,
+			"Unterminated backtick in volume specfication file at "
+                        "line (%d), column (%d).", line, column);
                 ret = -1;
 	}
 
@@ -573,8 +567,8 @@ glusterfs_graph_construct (FILE *fp)
 
         ret = unlink (template);
         if (ret < 0) {
-                gf_log ("parser", GF_LOG_WARNING, "Unable to delete file: %s",
-                        template);
+                gf_msg ("parser", GF_LOG_WARNING, 0, LG_MSG_FILE_OP_FAILED,
+                        "Unable to delete file: %s", template);
         }
 
         tmp_file = fdopen (tmp_fd, "w+b");
@@ -583,7 +577,8 @@ glusterfs_graph_construct (FILE *fp)
 
         ret = preprocess (fp, tmp_file);
         if (ret < 0) {
-                gf_log ("parser", GF_LOG_ERROR, "parsing of backticks failed");
+                gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_BACKTICK_PARSE_FAILED,
+                        "parsing of backticks failed");
                 goto err;
         }
 
@@ -597,9 +592,8 @@ glusterfs_graph_construct (FILE *fp)
 	pthread_mutex_unlock (&graph_mutex);
 
         if (ret == 1) {
-                gf_log ("parser", GF_LOG_DEBUG,
-                        "parsing of volfile failed, please review it "
-                        "once more");
+                gf_msg_debug ("parser", 0, "parsing of volfile failed, please "
+                              "review it once more");
                 goto err;
         }
 
@@ -609,7 +603,8 @@ err:
         if (tmp_file) {
                 fclose (tmp_file);
         } else {
-                gf_log ("parser", GF_LOG_ERROR, "cannot create temporary file");
+                gf_msg ("parser", GF_LOG_ERROR, 0, LG_MSG_FILE_OP_FAILED,
+                        "cannot create temporary file");
                 if (-1 != tmp_fd)
                         close (tmp_fd);
         }
-- 
1.7.1