summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/src/glfs.c3
-rw-r--r--cli/src/cli.c3
-rw-r--r--doc/logging.txt11
-rw-r--r--glusterfsd/src/glusterfsd.c24
-rw-r--r--libglusterfs/src/logging.c49
-rw-r--r--libglusterfs/src/logging.h3
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog.c3
7 files changed, 66 insertions, 30 deletions
diff --git a/api/src/glfs.c b/api/src/glfs.c
index efda6b6..9fa0a46 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -477,7 +477,8 @@ glfs_set_logging (struct glfs *fs, const char *logfile, int loglevel)
int ret = 0;
if (logfile) {
- ret = gf_log_init (fs->ctx, logfile);
+ /* passing ident as NULL means to use default ident for syslog */
+ ret = gf_log_init (fs->ctx, logfile, NULL);
if (ret)
return ret;
}
diff --git a/cli/src/cli.c b/cli/src/cli.c
index 37015c3..f87038b 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -168,7 +168,8 @@ logging_init (glusterfs_ctx_t *ctx, struct cli_state *state)
char *log_file = state->log_file ? state->log_file :
DEFAULT_CLI_LOG_FILE_DIRECTORY "/cli.log";
- if (gf_log_init (ctx, log_file) == -1) {
+ /* passing ident as NULL means to use default ident for syslog */
+ if (gf_log_init (ctx, log_file, NULL) == -1) {
fprintf (stderr, "ERROR: failed to open logfile %s\n",
log_file);
return -1;
diff --git a/doc/logging.txt b/doc/logging.txt
index 71e4301..e4a8575 100644
--- a/doc/logging.txt
+++ b/doc/logging.txt
@@ -55,11 +55,12 @@ gf_syslog (GF_ERR_DEV, LOG_ERR, "error reading configuration file");
The logs are sent in CEE format (http://cee.mitre.org/) to syslog.
Its targeted to rsyslog syslog server.
-This log framework can be disabled either at compile time or run time
+This log framework is enabled at compile time by default. This can be
+disabled by passing '--disable-syslog' to ./configure or '--without
+syslog' to rpmbuild
-- for compile time by passing '--disable-syslog' to ./configure or
- '--without syslog' to rpmbuild (or)
-- for run time by having a file /var/lib/glusterd/logger.conf and
- restarting gluster services
+Even though its enabled at compile time, its required to have
+/var/lib/glusterd/logger.conf file to make it into effect before
+starting gluster services
Currently all gluster logs are sent with error code GF_ERR_DEV.
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index 695f456..ad0b29e 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -1334,10 +1334,13 @@ out:
}
static int
-logging_init (glusterfs_ctx_t *ctx)
+logging_init (glusterfs_ctx_t *ctx, const char *progpath)
{
cmd_args_t *cmd_args = NULL;
int ret = 0;
+ char ident[1024] = {0,};
+ char *progname = NULL;
+ char *ptr = NULL;
cmd_args = &ctx->cmd_args;
@@ -1349,7 +1352,22 @@ logging_init (glusterfs_ctx_t *ctx)
}
}
- if (gf_log_init (ctx, cmd_args->log_file) == -1) {
+#ifdef GF_USE_SYSLOG
+ progname = gf_strdup (progpath);
+ snprintf (ident, 1024, "%s_%s", basename(progname),
+ basename(cmd_args->log_file));
+ GF_FREE (progname);
+ /* remove .log suffix */
+ if (NULL != (ptr = strrchr(ident, '.'))) {
+ if (strcmp(ptr, ".log") == 0) {
+ /* note: ptr points to location in ident only */
+ ptr[0] = '\0';
+ }
+ }
+ ptr = ident;
+#endif
+
+ if (gf_log_init (ctx, cmd_args->log_file, ptr) == -1) {
fprintf (stderr, "ERROR: failed to open logfile %s\n",
cmd_args->log_file);
return -1;
@@ -1911,7 +1929,7 @@ main (int argc, char *argv[])
if (ret)
goto out;
- ret = logging_init (ctx);
+ ret = logging_init (ctx, argv[0]);
if (ret)
goto out;
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index ad2f788..abb6b05 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 3c65bf4..9da1379 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);
diff --git a/xlators/features/changelog/lib/src/gf-changelog.c b/xlators/features/changelog/lib/src/gf-changelog.c
index 4e60bb2..15c6e84 100644
--- a/xlators/features/changelog/lib/src/gf-changelog.c
+++ b/xlators/features/changelog/lib/src/gf-changelog.c
@@ -467,7 +467,8 @@ gf_changelog_register (char *brick_path, char *scratch_dir,
goto cleanup;
}
- if (gf_log_init (this->ctx, log_file))
+ /* passing ident as NULL means to use default ident for syslog */
+ if (gf_log_init (this->ctx, log_file, NULL))
goto cleanup;
gf_log_set_loglevel ((log_level == -1) ? GF_LOG_INFO :