summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/logging.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/logging.c')
-rw-r--r--libglusterfs/src/logging.c49
1 files changed, 31 insertions, 18 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