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