summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorBala.FA <barumuga@redhat.com>2013-08-09 16:51:11 +0530
committerVijay Bellur <vbellur@redhat.com>2013-08-13 07:07:43 -0700
commit4e63eafaed6073eab3d87c579e964fa5302f0d63 (patch)
tree1fba739f316a595141d0faee09c823326f0f4802 /libglusterfs
parenta1fe3d040a8c9b032cbcb5e831383628cddfa39a (diff)
log: set ident to openlog
at syslog side, log message is identified by its properties like programname, pid, etc. brick/mount processes need to be identified uniquely as they are different process of gluterfsd/glusterfs. At rsyslog side, log separated by programname/app-name with pid works but bit hard to identify them in long run which process is for what brick/mount. This patch fixes by setting identity string at openlog() which sets programname/app-name as similar to old style log file prefixed by gluster, glusterd, glusterfs or glusterfsd Change-Id: Ia05068943fa67ae1663aaded1444cf84ea648db8 BUG: 928648 Signed-off-by: Bala.FA <barumuga@redhat.com> Reviewed-on: http://review.gluster.org/5541 Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/logging.c49
-rw-r--r--libglusterfs/src/logging.h3
2 files changed, 33 insertions, 19 deletions
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index ad2f78835e8..abb6b05eb63 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -326,34 +326,47 @@ gf_log_globals_init (void *data)
ctx->log.gf_log_syslog = 1;
ctx->log.sys_log_level = GF_LOG_CRITICAL;
-#if defined(GF_USE_SYSLOG)
- {
- /* use default ident and option */
- /* TODO: make FACILITY configurable than LOG_DAEMON */
- struct stat buf;
-
- if (stat (GF_LOG_CONTROL_FILE, &buf) == 0) {
- ctx->log.log_control_file_found = 1; /* use gf_log */
- } else {
- ctx->log.log_control_file_found = 0;
- gf_openlog (NULL, -1, LOG_DAEMON);
- }
- }
-#elif defined(GF_LINUX_HOST_OS)
+#ifndef GF_USE_SYSLOG
+#ifdef GF_LINUX_HOST_OS
/* For the 'syslog' output. one can grep 'GlusterFS' in syslog
for serious logs */
openlog ("GlusterFS", LOG_PID, LOG_DAEMON);
#endif
+#endif
}
int
-gf_log_init (void *data, const char *file)
+gf_log_init (void *data, const char *file, const char *ident)
{
glusterfs_ctx_t *ctx = NULL;
int fd = -1;
ctx = data;
+#if defined(GF_USE_SYSLOG)
+ {
+ /* use default ident and option */
+ /* TODO: make FACILITY configurable than LOG_DAEMON */
+ struct stat buf;
+
+ if (stat (GF_LOG_CONTROL_FILE, &buf) == 0) {
+ /* use syslog logging */
+ ctx->log.log_control_file_found = 1;
+ if (ident) {
+ /* we need to keep this value as */
+ /* syslog uses it on every logging */
+ ctx->log.ident = gf_strdup (ident);
+ gf_openlog (ctx->log.ident, -1, LOG_DAEMON);
+ } else {
+ gf_openlog (NULL, -1, LOG_DAEMON);
+ }
+ } else {
+ /* use old style logging */
+ ctx->log.log_control_file_found = 0;
+ }
+ }
+#endif
+
if (!file){
fprintf (stderr, "ERROR: no filename specified\n");
return -1;
@@ -474,7 +487,7 @@ _gf_log_nomem (const char *domain, const char *file,
#endif /* HAVE_BACKTRACE */
#if defined(GF_USE_SYSLOG)
- if (!(ctx->log.log_control_file_found))
+ if (ctx->log.log_control_file_found)
{
int priority;
/* treat GF_LOG_TRACE and GF_LOG_NONE as LOG_DEBUG and
@@ -609,7 +622,7 @@ _gf_log_callingfn (const char *domain, const char *file, const char *function,
#endif /* HAVE_BACKTRACE */
#if defined(GF_USE_SYSLOG)
- if (!(ctx->log.log_control_file_found))
+ if (ctx->log.log_control_file_found)
{
int priority;
/* treat GF_LOG_TRACE and GF_LOG_NONE as LOG_DEBUG and
@@ -746,7 +759,7 @@ _gf_log (const char *domain, const char *file, const char *function, int line,
basename = file;
#if defined(GF_USE_SYSLOG)
- if (!(ctx->log.log_control_file_found))
+ if (ctx->log.log_control_file_found)
{
int priority;
/* treat GF_LOG_TRACE and GF_LOG_NONE as LOG_DEBUG and
diff --git a/libglusterfs/src/logging.h b/libglusterfs/src/logging.h
index 3c65bf4a9dc..9da1379e7ca 100644
--- a/libglusterfs/src/logging.h
+++ b/libglusterfs/src/logging.h
@@ -74,12 +74,13 @@ typedef struct gf_log_handle_ {
FILE *cmdlogfile;
#ifdef GF_USE_SYSLOG
int log_control_file_found;
+ char *ident;
#endif /* GF_USE_SYSLOG */
} gf_log_handle_t;
void gf_log_globals_init (void *ctx);
-int gf_log_init (void *data, const char *filename);
+int gf_log_init (void *data, const char *filename, const char *ident);
void gf_log_logrotate (int signum);