diff options
author | Mohamed Ashiq Liyazudeen <mliyazud@redhat.com> | 2015-07-01 11:09:01 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2015-07-01 02:16:03 -0700 |
commit | f321a87f9eea3272a92b94d9e3a09e308d584974 (patch) | |
tree | 0d321b97379557a36795a255fb698f3526b44f59 /libglusterfs/src/common-utils.h | |
parent | 243a5b429f225acb8e7132264fe0a0835ff013d5 (diff) |
common-utils/libglusterfs : port log messages to a new framework
Backport of http://review.gluster.org/10824/
http://review.gluster.org/11400/
Cherry picked from 515a4c4e08eb9fcd92c9cca693ef9978b8a1b05c
>Change-Id: Iee1c083774c988375a7261cfd6d510ed4c574de2
>BUG: 1194640
>Signed-off-by: Mohamed Ashiq <ashiq333@gmail.com>
>Reviewed-on: http://review.gluster.org/10824
>Tested-by: Gluster Build System <jenkins@build.gluster.com>
>Reviewed-by: Kaushal M <kaushal@redhat.com>
Change-Id: Iee1c083774c988375a7261cfd6d510ed4c574de2
BUG: 1217722
Signed-off-by: Mohamed Ashiq <ashiq333@gmail.com>
Reviewed-on: http://review.gluster.org/11289
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'libglusterfs/src/common-utils.h')
-rw-r--r-- | libglusterfs/src/common-utils.h | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index 64a9040d20e..43ff5d78cf4 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -42,6 +42,8 @@ void trap (void); #include "locking.h" #include "mem-pool.h" #include "compat-uuid.h" +#include "uuid.h" +#include "libglusterfs-messages.h" #define STRINGIFY(val) #val #define TOSTRING(val) STRINGIFY(val) @@ -177,9 +179,10 @@ int gf_set_log_ident (cmd_args_t *cmd_args); #define VALIDATE_OR_GOTO(arg,label) do { \ if (!arg) { \ errno = EINVAL; \ - gf_log_callingfn ((this ? (this->name) : \ + gf_msg_callingfn ((this ? (this->name) : \ "(Govinda! Govinda!)"), \ - GF_LOG_WARNING, \ + GF_LOG_WARNING, EINVAL, \ + LG_MSG_INVALID_ARG, \ "invalid argument: " #arg); \ goto label; \ } \ @@ -188,7 +191,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); #define GF_VALIDATE_OR_GOTO(name,arg,label) do { \ if (!arg) { \ errno = EINVAL; \ - gf_log_callingfn (name, GF_LOG_ERROR, \ + gf_msg_callingfn (name, GF_LOG_ERROR, errno, \ + LG_MSG_INVALID_ARG, \ "invalid argument: " #arg); \ goto label; \ } \ @@ -197,7 +201,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); #define GF_VALIDATE_OR_GOTO_WITH_ERROR(name, arg, label, errno, error) do { \ if (!arg) { \ errno = error; \ - gf_log_callingfn (name, GF_LOG_ERROR, \ + gf_msg_callingfn (name, GF_LOG_ERROR, EINVAL, \ + LG_MSG_INVALID_ARG, \ "invalid argument: " #arg); \ goto label; \ } \ @@ -213,7 +218,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); #define GF_CHECK_ALLOC_AND_LOG(name, item, retval, msg, errlabel) do { \ if (!(item)) { \ (retval) = -ENOMEM; \ - gf_log (name, GF_LOG_CRITICAL, (msg)); \ + gf_msg (name, GF_LOG_CRITICAL, ENOMEM, \ + LG_MSG_NO_MEMORY, (msg)); \ goto errlabel; \ } \ } while (0) @@ -231,7 +237,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); GF_VALIDATE_OR_GOTO (name, arg, label); \ if ((arg[0]) != '/') { \ errno = EINVAL; \ - gf_log_callingfn (name, GF_LOG_ERROR, \ + gf_msg_callingfn (name, GF_LOG_ERROR, EINVAL, \ + LG_MSG_INVALID_ARG, \ "invalid argument: " #arg); \ goto label; \ } \ @@ -250,8 +257,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); #define GF_REMOVE_INTERNAL_XATTR(pattern, dict) \ do { \ if (!dict) { \ - gf_log (this->name, GF_LOG_ERROR, \ - "dict is null"); \ + gf_msg (this->name, GF_LOG_ERROR, 0, \ + LG_MSG_DICT_NULL, "dict is null"); \ break; \ } \ dict_foreach_fnmatch (dict, pattern, \ @@ -262,7 +269,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); #define GF_IF_INTERNAL_XATTR_GOTO(pattern, dict, op_errno, label) \ do { \ if (!dict) { \ - gf_log (this->name, GF_LOG_ERROR, \ + gf_msg (this->name, GF_LOG_ERROR, 0, \ + LG_MSG_DICT_NULL, \ "setxattr dict is null"); \ goto label; \ } \ @@ -270,10 +278,10 @@ int gf_set_log_ident (cmd_args_t *cmd_args); dict_null_foreach_fn, \ NULL) > 0) { \ op_errno = EPERM; \ - gf_log (this->name, GF_LOG_ERROR, \ + gf_msg (this->name, GF_LOG_ERROR, op_errno, \ + LG_MSG_NO_PERM, \ "attempt to set internal" \ - " xattr: %s: %s", pattern, \ - strerror (op_errno)); \ + " xattr: %s", pattern); \ goto label; \ } \ } while (0) @@ -281,13 +289,15 @@ int gf_set_log_ident (cmd_args_t *cmd_args); #define GF_IF_NATIVE_XATTR_GOTO(pattern, key, op_errno, label) \ do { \ if (!key) { \ - gf_log (this->name, GF_LOG_ERROR, \ + gf_msg (this->name, GF_LOG_ERROR, 0, \ + LG_MSG_NO_KEY, \ "no key for removexattr"); \ goto label; \ } \ if (!fnmatch (pattern, key, 0)) { \ op_errno = EPERM; \ - gf_log (this->name, GF_LOG_ERROR, \ + gf_msg (this->name, GF_LOG_ERROR, op_errno, \ + LG_MSG_NO_PERM, \ "attempt to remove internal " \ "xattr: %s: %s", key, \ strerror (op_errno)); \ @@ -305,7 +315,8 @@ int gf_set_log_ident (cmd_args_t *cmd_args); #define GF_ASSERT(x) \ do { \ if (!(x)) { \ - gf_log_callingfn ("", GF_LOG_ERROR, \ + gf_msg_callingfn ("", GF_LOG_ERROR, 0, \ + LG_MSG_ASSERTION_FAILED, \ "Assertion failed: " #x); \ } \ } while (0) |