diff options
author | Mohamed Ashiq <ashiq333@gmail.com> | 2015-05-19 15:40:30 +0530 |
---|---|---|
committer | Niels de Vos <ndevos@redhat.com> | 2015-07-13 06:10:58 -0700 |
commit | 1e4cc18362df17f87001ec42605b51daf251e0db (patch) | |
tree | 3e948e6a44979b7316b73a8f931e7e537716bf03 /libglusterfs/src/logging.c | |
parent | 0497fb6090d1ed34ac1bdcaaff49847025d13e9e (diff) |
defaults,globals,iobuf,latency,logging,options,xlator/libglusterfs : porting to a new logging framework
Backport of http://review.gluster.org/10826
Cherry picked from ef374774b8727b2f76915a1f88b26c83c77dde43
>Change-Id: If6a55186cddc3d1c4d22e3d56b45358b84feeb49
>BUG: 1194640
>Signed-off-by: Mohamed Ashiq <ashiq333@gmail.com>
>Reviewed-on: http://review.gluster.org/10826
>Tested-by: NetBSD Build System <jenkins@build.gluster.org>
>Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Change-Id: If6a55186cddc3d1c4d22e3d56b45358b84feeb49
BUG: 1217722
Signed-off-by: Mohamed Ashiq <ashiq333@gmail.com>
Reviewed-on: http://review.gluster.org/11405
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'libglusterfs/src/logging.c')
-rw-r--r-- | libglusterfs/src/logging.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index e8fca2db916..44f5cd2cff5 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -44,6 +44,7 @@ #include "defaults.h" #include "glusterfs.h" #include "timer.h" +#include "libglusterfs-messages.h" /* Do not replace gf_log in TEST_LOG with gf_msg, as there is a slight chance * that it could lead to an infinite recursion.*/ @@ -381,17 +382,18 @@ gf_log_rotate(glusterfs_ctx_t *ctx) fd = open (ctx->log.filename, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR); if (fd < 0) { - gf_log ("logrotate", GF_LOG_ERROR, - "%s", strerror (errno)); + gf_msg ("logrotate", GF_LOG_ERROR, errno, + LG_MSG_FILE_OP_FAILED, "failed to open " + "logfile"); return; } close (fd); new_logfile = fopen (ctx->log.filename, "a"); if (!new_logfile) { - gf_log ("logrotate", GF_LOG_CRITICAL, - "failed to open logfile %s (%s)", - ctx->log.filename, strerror (errno)); + gf_msg ("logrotate", GF_LOG_CRITICAL, errno, + LG_MSG_FILE_OP_FAILED, "failed to open logfile" + " %s", ctx->log.filename); return; } @@ -2190,17 +2192,19 @@ _gf_log (const char *domain, const char *file, const char *function, int line, fd = open (ctx->log.filename, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR); if (fd < 0) { - gf_log ("logrotate", GF_LOG_ERROR, - "%s", strerror (errno)); + gf_msg ("logrotate", GF_LOG_ERROR, errno, + LG_MSG_FILE_OP_FAILED, + "failed to open logfile"); return -1; } close (fd); new_logfile = fopen (ctx->log.filename, "a"); if (!new_logfile) { - gf_log ("logrotate", GF_LOG_CRITICAL, - "failed to open logfile %s (%s)", - ctx->log.filename, strerror (errno)); + gf_msg ("logrotate", GF_LOG_CRITICAL, errno, + LG_MSG_FILE_OP_FAILED, + "failed to open logfile %s", + ctx->log.filename); goto log; } @@ -2345,15 +2349,13 @@ gf_cmd_log_init (const char *filename) return -1; if (!filename){ - gf_log (this->name, GF_LOG_CRITICAL, "gf_cmd_log_init: no " - "filename specified\n"); + gf_msg (this->name, GF_LOG_CRITICAL, 0, LG_MSG_INVALID_ENTRY, + "gf_cmd_log_init: no filename specified\n"); return -1; } ctx->log.cmd_log_filename = gf_strdup (filename); if (!ctx->log.cmd_log_filename) { - gf_log (this->name, GF_LOG_CRITICAL, - "gf_cmd_log_init: strdup error\n"); return -1; } /* close and reopen cmdlogfile for log rotate*/ @@ -2365,17 +2367,18 @@ gf_cmd_log_init (const char *filename) fd = open (ctx->log.cmd_log_filename, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR); if (fd < 0) { - gf_log (this->name, GF_LOG_CRITICAL, - "%s", strerror (errno)); + gf_msg (this->name, GF_LOG_CRITICAL, errno, + LG_MSG_FILE_OP_FAILED, "failed to open cmd_log_file"); return -1; } close (fd); ctx->log.cmdlogfile = fopen (ctx->log.cmd_log_filename, "a"); if (!ctx->log.cmdlogfile){ - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, errno, + LG_MSG_FILE_OP_FAILED, "gf_cmd_log_init: failed to open logfile \"%s\" " - "(%s)\n", ctx->log.cmd_log_filename, strerror (errno)); + "\n", ctx->log.cmd_log_filename); return -1; } return 0; @@ -2404,7 +2407,7 @@ gf_cmd_log (const char *domain, const char *fmt, ...) if (!domain || !fmt) { - gf_log ("glusterd", GF_LOG_TRACE, + gf_msg_trace ("glusterd", 0, "logging: invalid argument\n"); return -1; } |