summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authoryatipadia <ypadia@redhat.com>2019-11-19 18:59:28 +0530
committerAmar Tumballi <amar@kadalu.io>2020-02-14 07:16:48 +0000
commitacbba8e1121205f9512833d1b0fad81b0930f881 (patch)
treed8f4472edf69b6bc14cedf8ec52d731bec94c9a9 /libglusterfs
parentc048df835e94a8707254d32db93c42f43f31abda (diff)
libglusterfs-xlator: structure logging
convert all gf_msg() to gf_smsg() Change-Id: Id542e05faadb8041b472a2298c71fe62730e65fc Updates: #657 Signed-off-by: yatipadia <ypadia@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/dict.c101
-rw-r--r--libglusterfs/src/glusterfs/libglusterfs-messages.h35
-rw-r--r--libglusterfs/src/logging.c54
-rw-r--r--libglusterfs/src/xlator.c86
4 files changed, 141 insertions, 135 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index ddd27ebd940..a1a6ad12527 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -1249,8 +1249,8 @@ data_to_iatt(data_t *data, char *key)
* pass more data but are backward compatible (if the initial contents
* of the struct are maintained, of course). */
if (data->len < sizeof(struct iatt)) {
- gf_msg("glusterfs", GF_LOG_ERROR, ENOBUFS, LG_MSG_UNDERSIZED_BUF,
- "data value for '%s' is smaller than expected", key);
+ gf_smsg("glusterfs", GF_LOG_ERROR, ENOBUFS, LG_MSG_UNDERSIZED_BUF,
+ "key=%s", key, NULL);
return NULL;
}
@@ -1267,8 +1267,8 @@ int
dict_remove_foreach_fn(dict_t *d, char *k, data_t *v, void *_tmp)
{
if (!d || !k) {
- gf_msg("glusterfs", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ENTRY,
- "%s is NULL", d ? "key" : "dictionary");
+ gf_smsg("glusterfs", GF_LOG_WARNING, EINVAL, LG_MSG_KEY_OR_VALUE_NULL,
+ "d=%s", d ? "key" : "dictionary", NULL);
return -1;
}
@@ -2103,8 +2103,8 @@ _dict_modify_flag(dict_t *this, char *key, int flag, int op)
} else {
ptr = GF_CALLOC(1, DICT_MAX_FLAGS / 8, gf_common_mt_char);
if (!ptr) {
- gf_msg("dict", GF_LOG_ERROR, ENOMEM, LG_MSG_NO_MEMORY,
- "unable to allocate flag bit array");
+ gf_smsg("dict", GF_LOG_ERROR, ENOMEM, LG_MSG_NO_MEMORY,
+ "flag bit array", NULL);
ret = -ENOMEM;
goto err;
}
@@ -2112,8 +2112,8 @@ _dict_modify_flag(dict_t *this, char *key, int flag, int op)
data = data_from_dynptr(ptr, DICT_MAX_FLAGS / 8);
if (!data) {
- gf_msg("dict", GF_LOG_ERROR, ENOMEM, LG_MSG_NO_MEMORY,
- "unable to allocate data");
+ gf_smsg("dict", GF_LOG_ERROR, ENOMEM, LG_MSG_NO_MEMORY, "data",
+ NULL);
GF_FREE(ptr);
ret = -ENOMEM;
goto err;
@@ -2127,8 +2127,8 @@ _dict_modify_flag(dict_t *this, char *key, int flag, int op)
if (this->free_pair.key) { /* the free pair is in use */
pair = mem_get0(THIS->ctx->dict_pair_pool);
if (!pair) {
- gf_msg("dict", GF_LOG_ERROR, ENOMEM, LG_MSG_NO_MEMORY,
- "unable to allocate dict pair");
+ gf_smsg("dict", GF_LOG_ERROR, ENOMEM, LG_MSG_NO_MEMORY,
+ "dict pair", NULL);
ret = -ENOMEM;
goto err;
}
@@ -2138,8 +2138,8 @@ _dict_modify_flag(dict_t *this, char *key, int flag, int op)
pair->key = (char *)GF_MALLOC(strlen(key) + 1, gf_common_mt_char);
if (!pair->key) {
- gf_msg("dict", GF_LOG_ERROR, ENOMEM, LG_MSG_NO_MEMORY,
- "unable to allocate dict pair");
+ gf_smsg("dict", GF_LOG_ERROR, ENOMEM, LG_MSG_NO_MEMORY,
+ "dict pair", NULL);
ret = -ENOMEM;
goto err;
}
@@ -2183,8 +2183,8 @@ err:
if (data)
data_destroy(data);
- gf_msg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_DICT_SET_FAILED,
- "unable to set key (%s) in dict ", key);
+ gf_smsg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_DICT_SET_FAILED, "key=%s", key,
+ NULL);
return ret;
}
@@ -2707,8 +2707,8 @@ dict_get_mdata(dict_t *this, char *key, struct mdata_iatt *mdata)
VALIDATE_DATA_AND_LOG(data, GF_DATA_TYPE_MDATA, key, -EINVAL);
if (data->len < sizeof(struct mdata_iatt)) {
- gf_msg("glusterfs", GF_LOG_ERROR, ENOBUFS, LG_MSG_UNDERSIZED_BUF,
- "data value for '%s' is smaller than expected", key);
+ gf_smsg("glusterfs", GF_LOG_ERROR, ENOBUFS, LG_MSG_UNDERSIZED_BUF,
+ "key=%s", key, NULL);
ret = -ENOBUFS;
goto err;
}
@@ -2876,39 +2876,36 @@ dict_serialized_length_lk(dict_t *this)
data_pair_t *pair = this->members_list;
if (count < 0) {
- gf_msg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_COUNT_LESS_THAN_ZERO,
- "count (%d) < 0!", count);
+ gf_smsg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_COUNT_LESS_THAN_ZERO,
+ "count=%d", count, NULL);
goto out;
}
while (count) {
if (!pair) {
- gf_msg("dict", GF_LOG_ERROR, EINVAL,
- LG_MSG_COUNT_LESS_THAN_DATA_PAIRS,
- "less than count data pairs found!");
+ gf_smsg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_PAIRS_LESS_THAN_COUNT,
+ NULL);
goto out;
}
len += DICT_DATA_HDR_KEY_LEN + DICT_DATA_HDR_VAL_LEN;
if (!pair->key) {
- gf_msg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_NULL_PTR,
- "pair->key is null!");
+ gf_smsg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_NULL_PTR, NULL);
goto out;
}
len += strlen(pair->key) + 1 /* for '\0' */;
if (!pair->value) {
- gf_msg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_NULL_PTR,
- "pair->value is null!");
+ gf_smsg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_NULL_PTR, NULL);
goto out;
}
if (pair->value->len < 0) {
- gf_msg("dict", GF_LOG_ERROR, EINVAL,
- LG_MSG_VALUE_LENGTH_LESS_THAN_ZERO, "value->len (%d) < 0",
- pair->value->len);
+ gf_smsg("dict", GF_LOG_ERROR, EINVAL,
+ LG_MSG_VALUE_LENGTH_LESS_THAN_ZERO, "len=%d",
+ pair->value->len, NULL);
goto out;
}
@@ -2945,14 +2942,13 @@ dict_serialize_lk(dict_t *this, char *buf)
int32_t netword = 0;
if (!buf) {
- gf_msg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG,
- "buf is null!");
+ gf_smsg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG, NULL);
goto out;
}
if (count < 0) {
- gf_msg("dict", GF_LOG_ERROR, 0, LG_MSG_COUNT_LESS_THAN_ZERO,
- "count (%d) < 0!", count);
+ gf_smsg("dict", GF_LOG_ERROR, 0, LG_MSG_COUNT_LESS_THAN_ZERO,
+ "count=%d", count, NULL);
goto out;
}
@@ -2962,14 +2958,13 @@ dict_serialize_lk(dict_t *this, char *buf)
while (count) {
if (!pair) {
- gf_msg("dict", GF_LOG_ERROR, 0, LG_MSG_PAIRS_LESS_THAN_COUNT,
- "less than count data pairs found!");
+ gf_smsg("dict", GF_LOG_ERROR, 0, LG_MSG_PAIRS_LESS_THAN_COUNT,
+ NULL);
goto out;
}
if (!pair->key) {
- gf_msg("dict", GF_LOG_ERROR, 0, LG_MSG_NULL_PTR,
- "pair->key is null!");
+ gf_smsg("dict", GF_LOG_ERROR, 0, LG_MSG_NULL_PTR, NULL);
goto out;
}
@@ -2979,8 +2974,7 @@ dict_serialize_lk(dict_t *this, char *buf)
buf += DICT_DATA_HDR_KEY_LEN;
if (!pair->value) {
- gf_msg("dict", GF_LOG_ERROR, 0, LG_MSG_NULL_PTR,
- "pair->value is null!");
+ gf_smsg("dict", GF_LOG_ERROR, 0, LG_MSG_NULL_PTR, NULL);
goto out;
}
@@ -3128,8 +3122,8 @@ dict_unserialize(char *orig_buf, int32_t size, dict_t **fill)
buf += DICT_HDR_LEN;
if (count < 0) {
- gf_msg("dict", GF_LOG_ERROR, 0, LG_MSG_COUNT_LESS_THAN_ZERO,
- "count (%d) <= 0", count);
+ gf_smsg("dict", GF_LOG_ERROR, 0, LG_MSG_COUNT_LESS_THAN_ZERO,
+ "count=%d", count, NULL);
goto out;
}
@@ -3285,32 +3279,30 @@ dict_serialize_value_with_delim_lk(dict_t *this, char *buf, int32_t *serz_len,
data_pair_t *pair = this->members_list;
if (!buf) {
- gf_msg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG, "buf is null");
+ gf_smsg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG, NULL);
goto out;
}
if (count < 0) {
- gf_msg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG,
- "count (%d) < 0", count);
+ gf_smsg("dict", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG, "count=%d",
+ count, NULL);
goto out;
}
while (count) {
if (!pair) {
- gf_msg("dict", GF_LOG_ERROR, 0, LG_MSG_PAIRS_LESS_THAN_COUNT,
- "less than count data pairs found");
+ gf_smsg("dict", GF_LOG_ERROR, 0, LG_MSG_PAIRS_LESS_THAN_COUNT,
+ NULL);
goto out;
}
if (!pair->key || !pair->value) {
- gf_msg("dict", GF_LOG_ERROR, 0, LG_MSG_KEY_OR_VALUE_NULL,
- "key or value is null");
+ gf_smsg("dict", GF_LOG_ERROR, 0, LG_MSG_KEY_OR_VALUE_NULL, NULL);
goto out;
}
if (!pair->value->data) {
- gf_msg("dict", GF_LOG_ERROR, 0, LG_MSG_NULL_VALUE_IN_DICT,
- "null value found in dict");
+ gf_smsg("dict", GF_LOG_ERROR, 0, LG_MSG_NULL_VALUE_IN_DICT, NULL);
goto out;
}
@@ -3402,12 +3394,11 @@ dict_dump_to_log(dict_t *dict)
ret = dict_dump_to_str(dict, dump, dump_size, format);
if (ret) {
- gf_msg("dict", GF_LOG_WARNING, 0, LG_MSG_FAILED_TO_LOG_DICT,
- "Failed to log dictionary");
+ gf_smsg("dict", GF_LOG_WARNING, 0, LG_MSG_FAILED_TO_LOG_DICT, NULL);
goto out;
}
- gf_msg("dict", GF_LOG_INFO, 0, LG_MSG_DICT_ERROR, "dict=%p (%s)", dict,
- dump);
+ gf_smsg("dict", GF_LOG_INFO, 0, LG_MSG_DICT_ERROR, "dict=%p", dict,
+ "dump=%s", dump, NULL);
out:
GF_FREE(dump);
@@ -3440,8 +3431,8 @@ dict_dump_to_statedump(dict_t *dict, char *dict_name, char *domain)
ret = dict_dump_to_str(dict, dump, dump_size, format);
if (ret) {
- gf_msg(domain, GF_LOG_WARNING, 0, LG_MSG_FAILED_TO_LOG_DICT,
- "Failed to log dictionary %s", dict_name);
+ gf_smsg(domain, GF_LOG_WARNING, 0, LG_MSG_FAILED_TO_LOG_DICT, "name=%s",
+ dict_name, NULL);
goto out;
}
gf_proc_dump_build_key(key, domain, "%s", dict_name);
diff --git a/libglusterfs/src/glusterfs/libglusterfs-messages.h b/libglusterfs/src/glusterfs/libglusterfs-messages.h
index 71fc5f662af..cb31dd7614b 100644
--- a/libglusterfs/src/glusterfs/libglusterfs-messages.h
+++ b/libglusterfs/src/glusterfs/libglusterfs-messages.h
@@ -118,7 +118,9 @@ GLFS_MSGID(
LG_MSG_PATH_OPEN_FAILED, LG_MSG_DISPATCH_HANDLER_FAILED,
LG_MSG_READ_FILE_FAILED, LG_MSG_ENTRIES_NOT_PROVIDED,
LG_MSG_ENTRIES_PROVIDED, LG_MSG_UNKNOWN_OPTION_TYPE,
- LG_MSG_OPTION_DEPRECATED);
+ LG_MSG_OPTION_DEPRECATED, LG_MSG_INVALID_INIT, LG_MSG_OBJECT_NULL,
+ LG_MSG_GRAPH_NOT_SET, LG_MSG_FILENAME_NOT_SPECIFIED, LG_MSG_STRUCT_MISS,
+ LG_MSG_METHOD_MISS, LG_MSG_INPUT_DATA_NULL, LG_MSG_OPEN_LOGFILE_FAILED);
#define LG_MSG_EPOLL_FD_CREATE_FAILED_STR "epoll fd creation failed"
#define LG_MSG_INVALID_POLL_IN_STR "invalid poll_in value"
@@ -208,5 +210,36 @@ GLFS_MSGID(
"page_size of iobufs in arena being added is greater than max available"
#define LG_MSG_POOL_NOT_FOUND_STR "pool not found"
#define LG_MSG_IOBUF_NOT_FOUND_STR "iobuf not found"
+#define LG_MSG_DLOPEN_FAILED_STR "DL open failed"
+#define LG_MSG_DLSYM_ERROR_STR "dlsym missing"
+#define LG_MSG_LOAD_FAILED_STR "Failed to load xlator options table"
+#define LG_MSG_INPUT_DATA_NULL_STR \
+ "input data is null. cannot update the lru limit of the inode table. " \
+ "continuing with older value."
+#define LG_MSG_INIT_FAILED_STR "No init() found"
+#define LG_MSG_VOLUME_ERROR_STR \
+ "Initialization of volume failed. review your volfile again."
+#define LG_MSG_TREE_NOT_FOUND_STR "Translator tree not found"
+#define LG_MSG_SET_LOG_LEVEL_STR "setting log level"
+#define LG_MSG_INVALID_INIT_STR \
+ "Invalid log-level. possible values are DEBUG|WARNING|ERROR|NONE|TRACE"
+#define LG_MSG_OBJECT_NULL_STR "object is null, returning false."
+#define LG_MSG_GRAPH_NOT_SET_STR "Graph is not set for xlator"
+#define LG_MSG_OPEN_LOGFILE_FAILED_STR "failed to open logfile"
+#define LG_MSG_STRDUP_ERROR_STR "failed to create metrics dir"
+#define LG_MSG_FILENAME_NOT_SPECIFIED_STR "no filename specified"
+#define LG_MSG_UNDERSIZED_BUF_STR "data value is smaller than expected"
+#define LG_MSG_DICT_SET_FAILED_STR "unable to set dict"
+#define LG_MSG_COUNT_LESS_THAN_ZERO_STR "count < 0!"
+#define LG_MSG_PAIRS_LESS_THAN_COUNT_STR "less than count data pairs found"
+#define LG_MSG_NULL_PTR_STR "pair->key is null!"
+#define LG_MSG_VALUE_LENGTH_LESS_THAN_ZERO_STR "value->len < 0"
+#define LG_MSG_INVALID_ARG_STR "buf is null"
+#define LG_MSG_KEY_OR_VALUE_NULL_STR "key or value is null"
+#define LG_MSG_NULL_VALUE_IN_DICT_STR "null value found in dict"
+#define LG_MSG_FAILED_TO_LOG_DICT_STR "Failed to log dictionary"
+#define LG_MSG_DICT_ERROR_STR "dict error"
+#define LG_MSG_STRUCT_MISS_STR "struct missing"
+#define LG_MSG_METHOD_MISS_STR "method missing(init)"
#endif /* !_LG_MESSAGES_H_ */
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index e900df08a4b..3d7d31772df 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -312,18 +312,16 @@ gf_log_rotate(glusterfs_ctx_t *ctx)
fd = sys_open(ctx->log.filename, O_CREAT | O_WRONLY | O_APPEND,
S_IRUSR | S_IWUSR);
if (fd < 0) {
- gf_msg("logrotate", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
- "failed to open "
- "logfile");
+ gf_smsg("logrotate", GF_LOG_ERROR, errno,
+ LG_MSG_OPEN_LOGFILE_FAILED, NULL);
return;
}
new_logfile = fdopen(fd, "a");
if (!new_logfile) {
- gf_msg("logrotate", GF_LOG_CRITICAL, errno, LG_MSG_FILE_OP_FAILED,
- "failed to open logfile"
- " %s",
- ctx->log.filename);
+ gf_smsg("logrotate", GF_LOG_CRITICAL, errno,
+ LG_MSG_OPEN_LOGFILE_FAILED, "filename=%s",
+ ctx->log.filename, NULL);
sys_close(fd);
return;
}
@@ -685,9 +683,8 @@ gf_log_init(void *data, const char *file, const char *ident)
}
if (mkdir_p(logdir, 0755, true)) {
/* EEXIST is handled in mkdir_p() itself */
- gf_msg("logging", GF_LOG_ERROR, 0, LG_MSG_STRDUP_ERROR,
- "failed to create metrics dir %s (%s)", logdir,
- strerror(errno));
+ gf_smsg("logging", GF_LOG_ERROR, 0, LG_MSG_STRDUP_ERROR,
+ "logdir=%s", logdir, "errno=%s", strerror(errno), NULL);
GF_FREE(logdir);
return -1;
}
@@ -2074,16 +2071,17 @@ _gf_log(const char *domain, const char *file, const char *function, int line,
fd = sys_open(ctx->log.filename, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR);
if (fd < 0) {
- gf_msg("logrotate", GF_LOG_ERROR, errno, LG_MSG_FILE_OP_FAILED,
- "failed to open logfile");
+ gf_smsg("logrotate", GF_LOG_ERROR, errno,
+ LG_MSG_OPEN_LOGFILE_FAILED, NULL);
return -1;
}
sys_close(fd);
new_logfile = fopen(ctx->log.filename, "a");
if (!new_logfile) {
- gf_msg("logrotate", GF_LOG_CRITICAL, errno, LG_MSG_FILE_OP_FAILED,
- "failed to open logfile %s", ctx->log.filename);
+ gf_smsg("logrotate", GF_LOG_CRITICAL, errno,
+ LG_MSG_OPEN_LOGFILE_FAILED, "filename=%s",
+ ctx->log.filename, NULL);
goto log;
}
@@ -2190,8 +2188,8 @@ gf_cmd_log_init(const char *filename)
return -1;
if (!filename) {
- gf_msg(this->name, GF_LOG_CRITICAL, 0, LG_MSG_INVALID_ENTRY,
- "gf_cmd_log_init: no filename specified\n");
+ gf_smsg(this->name, GF_LOG_CRITICAL, 0, LG_MSG_FILENAME_NOT_SPECIFIED,
+ "gf_cmd_log_init", NULL);
return -1;
}
@@ -2208,17 +2206,15 @@ gf_cmd_log_init(const char *filename)
fd = sys_open(ctx->log.cmd_log_filename, O_CREAT | O_WRONLY | O_APPEND,
S_IRUSR | S_IWUSR);
if (fd < 0) {
- gf_msg(this->name, GF_LOG_CRITICAL, errno, LG_MSG_FILE_OP_FAILED,
- "failed to open cmd_log_file");
+ gf_smsg(this->name, GF_LOG_CRITICAL, errno, LG_MSG_OPEN_LOGFILE_FAILED,
+ "cmd_log_file", NULL);
return -1;
}
ctx->log.cmdlogfile = fdopen(fd, "a");
if (!ctx->log.cmdlogfile) {
- gf_msg(this->name, GF_LOG_CRITICAL, errno, LG_MSG_FILE_OP_FAILED,
- "gf_cmd_log_init: failed to open logfile \"%s\" "
- "\n",
- ctx->log.cmd_log_filename);
+ gf_smsg(this->name, GF_LOG_CRITICAL, errno, LG_MSG_OPEN_LOGFILE_FAILED,
+ "gf_cmd_log_init: %s", ctx->log.cmd_log_filename, NULL);
sys_close(fd);
return -1;
}
@@ -2282,20 +2278,18 @@ gf_cmd_log(const char *domain, const char *fmt, ...)
fd = sys_open(ctx->log.cmd_log_filename, O_CREAT | O_WRONLY | O_APPEND,
S_IRUSR | S_IWUSR);
if (fd < 0) {
- gf_msg(THIS->name, GF_LOG_CRITICAL, errno, LG_MSG_FILE_OP_FAILED,
- "failed to open "
- "logfile \"%s\" \n",
- ctx->log.cmd_log_filename);
+ gf_smsg(THIS->name, GF_LOG_CRITICAL, errno,
+ LG_MSG_OPEN_LOGFILE_FAILED, "name=%s",
+ ctx->log.cmd_log_filename, NULL);
ret = -1;
goto out;
}
ctx->log.cmdlogfile = fdopen(fd, "a");
if (!ctx->log.cmdlogfile) {
- gf_msg(THIS->name, GF_LOG_CRITICAL, errno, LG_MSG_FILE_OP_FAILED,
- "failed to open logfile \"%s\""
- " \n",
- ctx->log.cmd_log_filename);
+ gf_smsg(THIS->name, GF_LOG_CRITICAL, errno,
+ LG_MSG_OPEN_LOGFILE_FAILED, "name=%s",
+ ctx->log.cmd_log_filename, NULL);
ret = -1;
sys_close(fd);
goto out;
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index 8605fbd0e6f..90a993afdd2 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -206,23 +206,22 @@ xlator_volopt_dynload(char *xlator_type, void **dl_handle,
handle = dlopen(name, RTLD_NOW);
if (!handle) {
- gf_msg("xlator", GF_LOG_WARNING, 0, LG_MSG_DLOPEN_FAILED, "%s",
- dlerror());
+ gf_smsg("xlator", GF_LOG_WARNING, 0, LG_MSG_DLOPEN_FAILED, "error=%s",
+ dlerror(), NULL);
goto out;
}
/* check new struct first, and then check this */
xlapi = dlsym(handle, "xlator_api");
if (!xlapi) {
- gf_msg("xlator", GF_LOG_ERROR, 0, LG_MSG_DLSYM_ERROR,
- "dlsym(xlator_api) missing: %s", dlerror());
+ gf_smsg("xlator", GF_LOG_ERROR, 0, LG_MSG_DLSYM_ERROR, "error=%s",
+ dlerror(), NULL);
goto out;
}
opt_list->given_opt = xlapi->options;
if (!opt_list->given_opt) {
- gf_msg("xlator", GF_LOG_ERROR, 0, LG_MSG_LOAD_FAILED,
- "Failed to load xlator options table");
+ gf_smsg("xlator", GF_LOG_ERROR, 0, LG_MSG_LOAD_FAILED, NULL);
goto out;
}
@@ -251,16 +250,16 @@ xlator_dynload_apis(xlator_t *xl)
xlapi = dlsym(handle, "xlator_api");
if (!xlapi) {
- gf_msg("xlator", GF_LOG_ERROR, 0, LG_MSG_DLSYM_ERROR,
- "dlsym(xlator_api) missing: %s", dlerror());
+ gf_smsg("xlator", GF_LOG_ERROR, 0, LG_MSG_DLSYM_ERROR, "dlsym=%s",
+ dlerror(), NULL);
ret = -1;
goto out;
}
xl->fops = xlapi->fops;
if (!xl->fops) {
- gf_msg("xlator", GF_LOG_WARNING, 0, LG_MSG_DLSYM_ERROR,
- "%s: struct missing (fops)", xl->name);
+ gf_smsg("xlator", GF_LOG_WARNING, 0, LG_MSG_STRUCT_MISS, "name=%s",
+ xl->name, NULL);
goto out;
}
@@ -271,8 +270,8 @@ xlator_dynload_apis(xlator_t *xl)
xl->init = xlapi->init;
if (!xl->init) {
- gf_msg("xlator", GF_LOG_WARNING, 0, LG_MSG_DLSYM_ERROR,
- "%s: method missing (init)", xl->name);
+ gf_smsg("xlator", GF_LOG_WARNING, 0, LG_MSG_METHOD_MISS, "name=%s",
+ xl->name, NULL);
goto out;
}
@@ -370,8 +369,8 @@ xlator_dynload(xlator_t *xl)
handle = dlopen(name, RTLD_NOW);
if (!handle) {
- gf_msg("xlator", GF_LOG_WARNING, 0, LG_MSG_DLOPEN_FAILED, "%s",
- dlerror());
+ gf_smsg("xlator", GF_LOG_WARNING, 0, LG_MSG_DLOPEN_FAILED, "error=%s",
+ dlerror(), NULL);
goto out;
}
xl->dlhandle = handle;
@@ -438,10 +437,8 @@ xlator_set_inode_lru_limit(xlator_t *this, void *data)
if (this->itable) {
if (!data) {
- gf_msg(this->name, GF_LOG_WARNING, 0, LG_MSG_INVALID_ENTRY,
- "input data is NULL. "
- "Cannot update the lru limit of the inode"
- " table. Continuing with older value");
+ gf_smsg(this->name, GF_LOG_WARNING, 0, LG_MSG_INPUT_DATA_NULL,
+ NULL);
goto out;
}
inode_lru_limit = *(int *)data;
@@ -615,18 +612,15 @@ xlator_init(xlator_t *xl)
xl->instance_name = NULL;
GF_ATOMIC_INIT(xl->xprtrefcnt, 0);
if (!xl->init) {
- gf_msg(xl->name, GF_LOG_WARNING, 0, LG_MSG_INIT_FAILED,
- "No init() found");
+ gf_smsg(xl->name, GF_LOG_WARNING, 0, LG_MSG_INIT_FAILED, NULL);
goto out;
}
ret = __xlator_init(xl);
if (ret) {
- gf_msg(xl->name, GF_LOG_ERROR, 0, LG_MSG_VOLUME_ERROR,
- "Initialization of volume '%s' failed,"
- " review your volfile again",
- xl->name);
+ gf_smsg(xl->name, GF_LOG_ERROR, 0, LG_MSG_VOLUME_ERROR, "name=%s",
+ xl->name, NULL);
goto out;
}
@@ -862,8 +856,7 @@ xlator_tree_free_members(xlator_t *tree)
xlator_t *prev = tree;
if (!tree) {
- gf_msg("parser", GF_LOG_ERROR, 0, LG_MSG_TREE_NOT_FOUND,
- "Translator tree not found");
+ gf_smsg("parser", GF_LOG_ERROR, 0, LG_MSG_TREE_NOT_FOUND, NULL);
return -1;
}
@@ -883,8 +876,7 @@ xlator_tree_free_memacct(xlator_t *tree)
xlator_t *prev = tree;
if (!tree) {
- gf_msg("parser", GF_LOG_ERROR, 0, LG_MSG_TREE_NOT_FOUND,
- "Translator tree not found");
+ gf_smsg("parser", GF_LOG_ERROR, 0, LG_MSG_TREE_NOT_FOUND, NULL);
return -1;
}
@@ -1344,9 +1336,9 @@ is_gf_log_command(xlator_t *this, const char *name, char *value, size_t size)
/* Some crude way to change the log-level of process */
if (!strcmp(name, "trusted.glusterfs.set-log-level")) {
- gf_msg("glusterfs", gf_log_get_loglevel(), 0, LG_MSG_SET_LOG_LEVEL,
- "setting log level to %d (old-value=%d)", log_level,
- gf_log_get_loglevel());
+ gf_smsg("glusterfs", gf_log_get_loglevel(), 0, LG_MSG_SET_LOG_LEVEL,
+ "new-value=%d", log_level, "old-value=%d",
+ gf_log_get_loglevel(), NULL);
gf_log_set_loglevel(this->ctx, log_level);
ret = 0;
goto out;
@@ -1354,9 +1346,9 @@ is_gf_log_command(xlator_t *this, const char *name, char *value, size_t size)
if (!strcmp(name, "trusted.glusterfs.fuse.set-log-level")) {
/* */
- gf_msg(this->name, gf_log_get_xl_loglevel(this), 0,
- LG_MSG_SET_LOG_LEVEL, "setting log level to %d (old-value=%d)",
- log_level, gf_log_get_xl_loglevel(this));
+ gf_smsg(this->name, gf_log_get_xl_loglevel(this), 0,
+ LG_MSG_SET_LOG_LEVEL, "new-value=%d", log_level, "old-value=%d",
+ gf_log_get_xl_loglevel(this), NULL);
gf_log_set_xl_loglevel(this, log_level);
ret = 0;
goto out;
@@ -1372,10 +1364,9 @@ is_gf_log_command(xlator_t *this, const char *name, char *value, size_t size)
while (trav) {
snprintf(key, 1024, "trusted.glusterfs.%s.set-log-level", trav->name);
if (fnmatch(name, key, FNM_NOESCAPE) == 0) {
- gf_msg(trav->name, gf_log_get_xl_loglevel(trav), 0,
- LG_MSG_SET_LOG_LEVEL,
- "setting log level to %d (old-value=%d)", log_level,
- gf_log_get_xl_loglevel(trav));
+ gf_smsg(trav->name, gf_log_get_xl_loglevel(trav), 0,
+ LG_MSG_SET_LOG_LEVEL, "new-value%d", log_level,
+ "old-value=%d", gf_log_get_xl_loglevel(trav), NULL);
gf_log_set_xl_loglevel(trav, log_level);
ret = 0;
}
@@ -1407,9 +1398,7 @@ glusterd_check_log_level(const char *value)
}
if (log_level == -1)
- gf_msg(THIS->name, GF_LOG_ERROR, 0, LG_MSG_INIT_FAILED,
- "Invalid log-level. possible values are "
- "DEBUG|WARNING|ERROR|CRITICAL|NONE|TRACE");
+ gf_smsg(THIS->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_INIT, NULL);
return log_level;
}
@@ -1486,8 +1475,7 @@ gluster_graph_take_reference(xlator_t *tree)
xlator_t *prev = tree;
if (!tree) {
- gf_msg("parser", GF_LOG_ERROR, 0, LG_MSG_TREE_NOT_FOUND,
- "Translator tree not found");
+ gf_smsg("parser", GF_LOG_ERROR, 0, LG_MSG_TREE_NOT_FOUND, NULL);
return;
}
@@ -1524,15 +1512,15 @@ xlator_is_cleanup_starting(xlator_t *this)
xlator_t *xl = NULL;
if (!this) {
- gf_msg("xlator", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ARG,
- "xlator object is null, returning false");
+ gf_smsg("xlator", GF_LOG_WARNING, EINVAL, LG_MSG_OBJECT_NULL, "xlator",
+ NULL);
goto out;
}
graph = this->graph;
if (!graph) {
- gf_msg("xlator", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ARG,
- "Graph is not set for xlator %s", this->name);
+ gf_smsg("xlator", GF_LOG_WARNING, EINVAL, LG_MSG_GRAPH_NOT_SET,
+ "name=%s", this->name, NULL);
goto out;
}
@@ -1550,8 +1538,8 @@ graph_total_client_xlator(glusterfs_graph_t *graph)
int count = 0;
if (!graph) {
- gf_msg("xlator", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ARG,
- "graph object is null");
+ gf_smsg("xlator", GF_LOG_WARNING, EINVAL, LG_MSG_OBJECT_NULL, "graph",
+ NULL);
goto out;
}