From 12efc4beb37e644af7c846f863929f0ba8dbebb0 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Fri, 6 Nov 2015 11:45:20 +0700 Subject: [PATCH] [#135] Switch default timestamp timezone to UTC, add some shorthands --- src/taoensso/timbre.cljx | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/taoensso/timbre.cljx b/src/taoensso/timbre.cljx index d8cd688..0877f61 100644 --- a/src/taoensso/timbre.cljx +++ b/src/taoensso/timbre.cljx @@ -25,11 +25,10 @@ #+clj (def default-timestamp-opts - "Controls (:timestamp_ data)." - {:pattern "yy-MMM-dd HH:mm:ss" - :locale (java.util.Locale. "en") - ;; :timezone (java.util.TimeZone/getTimeZone "UTC") - :timezone (java.util.TimeZone/getDefault)}) + "Controls (:timestamp_ data)" + {:pattern "yy-MMM-dd HH:mm:ss" #_:iso8601 + :locale :jvm-default #_(java.util.Locale. "en") + :timezone :utc #_(java.util.TimeZone/getTimeZone "Europe/Amsterdam")}) (declare stacktrace) (defn default-output-fn @@ -378,7 +377,25 @@ (let [timestamp-opts (inherit-into :timestamp-opts appender config default-timestamp-opts) - {:keys [pattern locale timezone]} timestamp-opts] + {:keys [pattern locale timezone]} timestamp-opts + + pattern + (case pattern + :iso8601 "yyyy-MM-dd HH:mm:ss.SSSZ" + :rss2 "EEE, dd MMM yyyy HH:mm:ss z" + pattern) + + locale + (case locale + :jvm-default (java.util.Locale/getDefault) + locale) + + timezone + (case timezone + :jvm-default (java.util.TimeZone/getDefault) + :utc (java.util.TimeZone/getTimeZone "UTC") + timezone)] + (.format (enc/simple-date-format pattern {:locale locale :timezone timezone}) (:instant data))))