summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamed Ashiq <ashiq333@gmail.com>2015-05-19 15:11:45 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-06-25 19:58:08 -0700
commit151c0ccf481d8e58581d7848f9aeb0e7704f0208 (patch)
tree742e9be4fb255597d1af1ce6f95c05db0334e161
parentd3714f252d91f4d1d5df05c4dcc8bc7c2ee75326 (diff)
graph/libglusterfs : porting to a new logging framework
Change-Id: I57ed5c979c15559443712a61f0b1a61c7f5557d8 BUG: 1194640 Signed-off-by: Mohamed Ashiq <ashiq333@gmail.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>
-rw-r--r--libglusterfs/src/graph-print.c16
-rw-r--r--libglusterfs/src/graph.c113
-rw-r--r--libglusterfs/src/graph.l2
-rw-r--r--libglusterfs/src/graph.y113
4 files changed, 126 insertions, 118 deletions
diff --git a/libglusterfs/src/graph-print.c b/libglusterfs/src/graph-print.c
index d352cc798b8..676167b17d2 100644
--- a/libglusterfs/src/graph-print.c
+++ b/libglusterfs/src/graph-print.c
@@ -13,7 +13,7 @@
#include "common-utils.h"
#include "xlator.h"
#include "graph-utils.h"
-
+#include "libglusterfs-messages.h"
struct gf_printer {
@@ -28,8 +28,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;
}
@@ -43,7 +43,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;
}
@@ -134,7 +135,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;
}
@@ -167,8 +169,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 61f72130af3..ed12b1c0e7f 100644
--- a/libglusterfs/src/graph.c
+++ b/libglusterfs/src/graph.c
@@ -16,6 +16,7 @@
#include "defaults.h"
#include <unistd.h>
+#include "libglusterfs-messages.h"
#if 0
static void
@@ -120,7 +121,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);
@@ -144,7 +145,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;
@@ -259,17 +260,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);
}
}
}
@@ -293,8 +295,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;
@@ -315,7 +318,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;
}
@@ -350,7 +354,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);
}
@@ -381,15 +386,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);
@@ -458,33 +463,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;
}
@@ -492,7 +501,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;
}
@@ -648,20 +657,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;
}
@@ -674,7 +687,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;
}
@@ -684,7 +698,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;
}
@@ -700,7 +715,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;
}
@@ -710,8 +725,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;
}
@@ -755,15 +770,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;
@@ -798,7 +811,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;
}
@@ -806,14 +819,15 @@ 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");
file_desc = mkstemp(temp_file);
if (file_desc < 0) {
- 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;
}
@@ -823,9 +837,9 @@ glusterfs_volfile_reconfigure (int oldvollen, FILE *newvolfile_fp,
u_ret = unlink(temp_file);
if (u_ret < 0) {
- gf_log ("glusterfsd-mgmt", GF_LOG_ERROR,
- "Temporary file delete failed. Reason: %s",
- strerror (errno));
+ gf_msg ("glusterfsd-mgmt", GF_LOG_ERROR, errno,
+ LG_MSG_TMPFILE_DELETE_FAILED, "Temporary file"
+ " delete failed.");
close (file_desc);
goto out;
}
@@ -857,21 +871,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 e4eba9cbef6..8af28a43539 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 42d638e5fd6..9fd02823a6c 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);
}