From dfdf3d9909f89989bf332ed4156e2034a6246a5c Mon Sep 17 00:00:00 2001
From: Russell Bryant <russell@russellbryant.com>
Date: Mon, 28 Jan 2013 01:50:54 +0000
Subject: [PATCH] Add queue_log_realtime_use_gmt option to logger.conf

Add an option that lets you specify that the timestamps going into the realtime
queue log should be in GMT instead of local time.

Review: https://reviewboard.asterisk.org/r/2287/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@380209 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 CHANGES                    | 3 +++
 configs/logger.conf.sample | 4 ++++
 main/logger.c              | 6 +++++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/CHANGES b/CHANGES
index 6e78fb02d5..2cc6145ecb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -67,6 +67,9 @@ Logging
    individual queue, the PAUSEALL/UNPAUSEALL event will only be logged if at
    least one member of any queue exists for that interface.
 
+ * Added the 'queue_log_realtime_use_gmt' option to have timestamps in GMT
+   for realtime queue log entries.
+
 Queue
 -------------------
  * Add queue available hint.  exten => 8501,hint,Queue:markq_avail
diff --git a/configs/logger.conf.sample b/configs/logger.conf.sample
index 406d6d8202..173fce9a38 100644
--- a/configs/logger.conf.sample
+++ b/configs/logger.conf.sample
@@ -39,6 +39,10 @@
 ; (defaults to queue_log)
 ;queue_log_name = queue_log
 ;
+; When using realtime for the queue log, use GMT for the timestamp
+; instead of localtime.  The default of this option is 'no'.
+;queue_log_realtime_use_gmt = yes
+;
 ; Log rotation strategy:
 ; none:  Do not perform any logrotation at all.  You should make
 ;        very sure to set up some external logrotate mechanism
diff --git a/main/logger.c b/main/logger.c
index 3caea6cc53..656117ce54 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -111,6 +111,7 @@ static struct {
 	unsigned int queue_log:1;
 	unsigned int queue_log_to_file:1;
 	unsigned int queue_adaptive_realtime:1;
+	unsigned int queue_log_realtime_use_gmt:1;
 } logfiles = { 1 };
 
 static char hostname[MAXHOSTNAMELEN];
@@ -427,6 +428,9 @@ static void init_logger_chain(int locked, const char *altconf)
 	if ((s = ast_variable_retrieve(cfg, "general", "queue_log_name"))) {
 		ast_copy_string(queue_log_name, s, sizeof(queue_log_name));
 	}
+	if ((s = ast_variable_retrieve(cfg, "general", "queue_log_realtime_use_gmt"))) {
+		logfiles.queue_log_realtime_use_gmt = ast_true(s);
+	}
 	if ((s = ast_variable_retrieve(cfg, "general", "exec_after_rotate"))) {
 		ast_copy_string(exec_after_rotate, s, sizeof(exec_after_rotate));
 	}
@@ -554,7 +558,7 @@ void ast_queue_log(const char *queuename, const char *callid, const char *agent,
 
 	if (ast_check_realtime("queue_log")) {
 		tv = ast_tvnow();
-		ast_localtime(&tv, &tm, NULL);
+		ast_localtime(&tv, &tm, logfiles.queue_log_realtime_use_gmt ? "GMT" : NULL);
 		ast_strftime(time_str, sizeof(time_str), "%F %T.%6q", &tm);
 		va_start(ap, fmt);
 		vsnprintf(qlog_msg, sizeof(qlog_msg), fmt, ap);
-- 
GitLab