From ae5f7c2c1d88cee0029c555f2416fe7c998cc1c2 Mon Sep 17 00:00:00 2001 From: Junaid Date: Wed, 29 Jun 2011 03:13:56 +0000 Subject: libglusterfs/logging: Added functions to set sys-log-level. Signed-off-by: Junaid Signed-off-by: Anand Avati BUG: 3044 (provide option to set syslog loglevel through CLI) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3044 --- libglusterfs/src/logging.c | 13 ++++++++++--- libglusterfs/src/logging.h | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index a492ac450..7db197928 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -50,6 +50,7 @@ static uint8_t logrotate = 0; static FILE *logfile = NULL; static gf_loglevel_t loglevel = GF_LOG_INFO; static int gf_log_syslog = 1; +static gf_loglevel_t sys_log_level = GF_LOG_CRITICAL; char gf_log_xl_log_set; gf_loglevel_t gf_log_loglevel = GF_LOG_INFO; /* extern'd */ @@ -186,6 +187,12 @@ gf_log_cleanup (void) pthread_mutex_destroy (&logfile_mutex); } +void +set_sys_log_level (gf_loglevel_t level) +{ + sys_log_level = level; +} + int _gf_log_nomem (const char *domain, const char *file, const char *function, int line, gf_loglevel_t level, @@ -291,7 +298,7 @@ _gf_log_nomem (const char *domain, const char *file, #ifdef GF_LINUX_HOST_OS /* We want only serious log in 'syslog', not our debug and trace logs */ - if (gf_log_syslog && level && (level <= GF_LOG_ERROR)) + if (gf_log_syslog && level && (level <= sys_log_level)) syslog ((level-1), "%s\n", msg); #endif } @@ -424,7 +431,7 @@ _gf_log_callingfn (const char *domain, const char *file, const char *function, #ifdef GF_LINUX_HOST_OS /* We want only serious log in 'syslog', not our debug and trace logs */ - if (gf_log_syslog && level && (level <= GF_LOG_CRITICAL)) + if (gf_log_syslog && level && (level <= sys_log_level)) syslog ((level-1), "%s\n", msg); #endif } @@ -562,7 +569,7 @@ log: #ifdef GF_LINUX_HOST_OS /* We want only serious log in 'syslog', not our debug and trace logs */ - if (gf_log_syslog && level && (level <= GF_LOG_CRITICAL)) + if (gf_log_syslog && level && (level <= sys_log_level)) syslog ((level-1), "%s\n", msg); #endif } diff --git a/libglusterfs/src/logging.h b/libglusterfs/src/logging.h index 0a76f1612..9441943a0 100644 --- a/libglusterfs/src/logging.h +++ b/libglusterfs/src/logging.h @@ -146,4 +146,6 @@ void gf_log_set_xl_loglevel (void *xl, gf_loglevel_t level); int gf_cmd_log (const char *domain, const char *fmt, ...); int gf_cmd_log_init (const char *filename); + +void set_sys_log_level (gf_loglevel_t level); #endif /* __LOGGING_H__ */ -- cgit