From 7c81fc58debe1c746f94bb7b1937729d9f2bd43a Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Fri, 28 Dec 2012 13:59:17 +0700 Subject: [PATCH] Fix `config` docstring --- project.clj | 5 +++-- src/taoensso/timbre.clj | 27 +++++++++++++-------------- src/taoensso/timbre/utils.clj | 11 ++++++++++- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/project.clj b/project.clj index 34ec8ef..66c1bce 100644 --- a/project.clj +++ b/project.clj @@ -2,8 +2,9 @@ :description "Clojure logging & profiling library" :url "https://github.com/ptaoussanis/timbre" :license {:name "Eclipse Public License"} - :dependencies [[org.clojure/clojure "1.3.0"] - [clj-stacktrace "0.2.5"]] + :dependencies [[org.clojure/clojure "1.3.0"] + [org.clojure/tools.macro "0.1.1"] + [clj-stacktrace "0.2.5"]] :profiles {:1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]} :1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]} :1.5 {:dependencies [[org.clojure/clojure "1.5.0-alpha3"]]} diff --git a/src/taoensso/timbre.clj b/src/taoensso/timbre.clj index 6092330..b879a36 100644 --- a/src/taoensso/timbre.clj +++ b/src/taoensso/timbre.clj @@ -16,24 +16,23 @@ (print (str (str/join \space xs) \newline)) (flush)) -(defonce config - ^{:doc - "This map atom controls everything about the way Timbre operates. In - particular note the flexibility to add arbitrary appenders. +(utils/defonce* config + "This map atom controls everything about the way Timbre operates. In + particular note the flexibility to add arbitrary appenders. - An appender is a map with keys: - :doc, :min-level, :enabled?, :async?, :max-message-per-msecs, :fn? + An appender is a map with keys: + :doc, :min-level, :enabled?, :async?, :max-message-per-msecs, :fn? - An appender's fn takes a single map argument with keys: - :level, :message, :more ; From all logging macros (`info`, etc.) - :profiling-stats ; From `profile` macro - :ap-config ; `shared-appender-config` - :prefix ; Output of `prefix-fn` + An appender's fn takes a single map argument with keys: + :level, :message, :more ; From all logging macros (`info`, etc.) + :profiling-stats ; From `profile` macro + :ap-config ; `shared-appender-config` + :prefix ; Output of `prefix-fn` - Other keys include: :instant, :timestamp, :hostname, :ns, :error? + Other keys include: :instant, :timestamp, :hostname, :ns, :error? - See source code for examples and `utils/deep-merge` for a convenient way - to reconfigure appenders."} + See source code for examples and `utils/deep-merge` for a convenient way + to reconfigure appenders." (atom {:current-level :debug ;;; Control log filtering by namespace patterns (e.g. ["my-app.*"]). diff --git a/src/taoensso/timbre/utils.clj b/src/taoensso/timbre/utils.clj index 61f97e0..5ac8e22 100644 --- a/src/taoensso/timbre/utils.clj +++ b/src/taoensso/timbre/utils.clj @@ -1,5 +1,14 @@ (ns taoensso.timbre.utils - {:author "Peter Taoussanis"}) + {:author "Peter Taoussanis"} + (:require [clojure.tools.macro :as macro])) + +(defmacro defonce* + "Like `clojure.core/defonce` but supports optional docstring and attributes + map for name symbol." + {:arglists '([name expr])} + [name & sigs] + (let [[name [expr]] (macro/name-with-attributes name sigs)] + `(clojure.core/defonce ~name ~expr))) (defn memoize-ttl "Like `memoize` but invalidates the cache for a set of arguments after TTL