From f68887999e89d894c3125e3b26517221ad1543fc Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Tue, 1 Aug 2017 08:04:48 -0400 Subject: logging: localtime logging, cmdline, volume set option Despite the fact that appliances generally use UTC, some users really want log entries in localtime. fixes gluster/glusterfs#272 feature page: https://review.gluster.org/17807 Change-Id: I5fbf2c3eedd9eb128fb3f851dd67b2f4081c8bba Signed-off-by: Kaleb S. KEITHLEY Reviewed-on: https://review.gluster.org/16911 CentOS-regression: Gluster Build System Smoke: Gluster Build System Reviewed-by: Samikshan Bairagya Reviewed-by: Shyamsundar Ranganathan --- libglusterfs/src/logging.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'libglusterfs/src/logging.c') diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index c09adecc4f1..0f238d00738 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -141,6 +141,31 @@ gf_log_set_loglevel (gf_loglevel_t level) ctx->log.loglevel = level; } +int +gf_log_get_localtime (void) +{ + glusterfs_ctx_t *ctx = NULL; + + ctx = THIS->ctx; + + if (ctx) + return ctx->log.localtime; + else + /* return global defaults (see gf_log_globals_init) */ + return 0; +} + +void +gf_log_set_localtime (int on_off) +{ + glusterfs_ctx_t *ctx = NULL; + + ctx = THIS->ctx; + + if (ctx) + ctx->log.localtime = on_off; +} + void gf_log_flush (void) { @@ -655,6 +680,7 @@ gf_log_globals_init (void *data, gf_loglevel_t level) ctx->log.logformat = gf_logformat_withmsgid; ctx->log.lru_size = GF_LOG_LRU_BUFSIZE_DEFAULT; ctx->log.timeout = GF_LOG_FLUSH_TIMEOUT_DEFAULT; + ctx->log.localtime = GF_LOG_LOCALTIME_DEFAULT; pthread_mutex_init (&ctx->log.log_buf_lock, NULL); -- cgit