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