qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject qpid-dispatch git commit: DISPATCH-1187: add options to log in UTC and to give control over the precise format of the date/time logged
Date Thu, 06 Dec 2018 17:27:03 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/master f080baabd -> 81d2555db


DISPATCH-1187: add options to log in UTC and to give control over the precise format of the
date/time logged


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/81d2555d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/81d2555d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/81d2555d

Branch: refs/heads/master
Commit: 81d2555db47ce02ccb31a0631956a23c5a0c7ab0
Parents: f080baa
Author: Gordon Sim <gsim@redhat.com>
Authored: Tue Dec 4 18:01:58 2018 +0000
Committer: Gordon Sim <gsim@redhat.com>
Committed: Thu Dec 6 17:10:08 2018 +0000

----------------------------------------------------------------------
 python/qpid_dispatch/management/qdrouter.json | 12 +++++++++++-
 src/dispatch.c                                |  3 +++
 src/dispatch_private.h                        |  2 ++
 src/log.c                                     | 11 ++++++++---
 src/log_private.h                             |  1 +
 5 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/81d2555d/python/qpid_dispatch/management/qdrouter.json
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch/management/qdrouter.json b/python/qpid_dispatch/management/qdrouter.json
index 5dbb8b5..5408c9b 100644
--- a/python/qpid_dispatch/management/qdrouter.json
+++ b/python/qpid_dispatch/management/qdrouter.json
@@ -469,7 +469,17 @@
                     "create": true,
                     "required": false,
                     "default": true
-                },                
+                },
+                "timestampsInUTC": {
+                    "type": "boolean",
+                    "description": "Use UTC time rather than localtime in logs.",
+                    "create": true
+                },
+                "timestampFormat": {
+                    "type": "string",
+                    "description": "Format string to use for timestamps in logs.",
+                    "create": true
+                },
                 "allowUnsettledMulticast": {
                     "type": "boolean",
                     "description": "(DEPRECATED) If true, allow senders to send unsettled
deliveries to multicast addresses.  These deliveries shall be settled by the ingress router.
 If false, unsettled deliveries to multicast addresses shall be rejected.",

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/81d2555d/src/dispatch.c
----------------------------------------------------------------------
diff --git a/src/dispatch.c b/src/dispatch.c
index 1c65057..4906b39 100644
--- a/src/dispatch.c
+++ b/src/dispatch.c
@@ -202,6 +202,8 @@ qd_error_t qd_dispatch_configure_router(qd_dispatch_t *qd, qd_entity_t
*entity)
 
     qd->thread_count = qd_entity_opt_long(entity, "workerThreads", 4); QD_ERROR_RET();
     qd->allow_resumable_link_route = qd_entity_opt_bool(entity, "allowResumableLinkRoute",
true); QD_ERROR_RET();
+    qd->timestamps_in_utc = qd_entity_opt_bool(entity, "timestampsInUTC", false); QD_ERROR_RET();
+    qd->timestamp_format = qd_entity_opt_string(entity, "timestampFormat", 0); QD_ERROR_RET();
 
     if (! qd->sasl_config_path) {
         qd->sasl_config_path = qd_entity_opt_string(entity, "saslConfigDir", 0); QD_ERROR_RET();
@@ -313,6 +315,7 @@ char * qd_dispatch_policy_host_pattern_lookup(qd_dispatch_t *qd, void
*py_obj)
 
 qd_error_t qd_dispatch_prepare(qd_dispatch_t *qd)
 {
+    qd_log_global_options(qd->timestamp_format, qd->timestamps_in_utc);
     qd->server             = qd_server(qd, qd->thread_count, qd->router_id, qd->sasl_config_path,
qd->sasl_config_name);
     qd->container          = qd_container(qd);
     qd->router             = qd_router(qd, qd->router_mode, qd->router_area, qd->router_id);

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/81d2555d/src/dispatch_private.h
----------------------------------------------------------------------
diff --git a/src/dispatch_private.h b/src/dispatch_private.h
index 36065dc..f5a089c 100644
--- a/src/dispatch_private.h
+++ b/src/dispatch_private.h
@@ -58,6 +58,8 @@ struct qd_dispatch_t {
     qd_router_mode_t  router_mode;
     bool   allow_resumable_link_route;
     bool   test_hooks;
+    bool   timestamps_in_utc;
+    char*  timestamp_format;
 };
 
 /**

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/81d2555d/src/log.c
----------------------------------------------------------------------
diff --git a/src/log.c b/src/log.c
index b102736..513b579 100644
--- a/src/log.c
+++ b/src/log.c
@@ -83,6 +83,12 @@ DEQ_DECLARE(log_sink_t, log_sink_list_t);
 static log_sink_list_t sink_list = {0};
 
 const char *format = "%Y-%m-%d %H:%M:%S.%%06lu %z";
+bool utc = false;
+
+void qd_log_global_options(const char* _format, bool _utc) {
+    if (_format) format = _format;
+    utc = _utc;
+}
 
 static const char* SINK_STDOUT = "stdout";
 static const char* SINK_STDERR = "stderr";
@@ -303,9 +309,9 @@ static void write_log(qd_log_source_t *log_source, qd_log_entry_t *entry)
         buf[0] = '\0';
 
         time_t sec = entry->time.tv_sec;
-        struct tm *local_tm = localtime(&sec);
+        struct tm *time = utc ? gmtime(&sec) : localtime(&sec);
         char fmt[100];
-        strftime(fmt, sizeof fmt, format, local_tm);
+        strftime(fmt, sizeof fmt, format, time);
         snprintf(buf, 100, fmt, entry->time.tv_usec);
 
         aprintf(&begin, end, "%s ", buf);
@@ -546,7 +552,6 @@ qd_error_t qd_log_entity(qd_entity_t *entity) {
         if (qd_entity_has(entity, "includeSource"))
             src->includeSource = qd_entity_get_bool(entity, "includeSource");
         QD_ERROR_BREAK();
-
     } while(0);
 
     if (module)

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/81d2555d/src/log_private.h
----------------------------------------------------------------------
diff --git a/src/log_private.h b/src/log_private.h
index c28c1f3..1f51490 100644
--- a/src/log_private.h
+++ b/src/log_private.h
@@ -22,6 +22,7 @@
 #include <qpid/dispatch/log.h>
 
 void qd_log_initialize(void);
+void qd_log_global_options(const char* format, bool utc);
 void qd_log_finalize(void);
 
 #define QD_LOG_TEXT_MAX 2048


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message