Merge branch 'dev'

This commit is contained in:
Peter Taoussanis 2015-08-07 23:42:04 +07:00
commit 3e4e81cc8a
6 changed files with 76 additions and 38 deletions

View File

@ -1,5 +1,17 @@
> This project uses [Break Versioning](https://github.com/ptaoussanis/encore/blob/master/BREAK-VERSIONING.md) as of **Aug 16, 2014**.
## v4.1.0 / 2015 Aug 7
> This is a non-breaking feature release
* **DEPRECATED**: `*context*` val is now located under a `:context` key in appender's data map [#116 @mikesperber]
* **New**: Added `profiling/fnp` macro
```clojure
[com.taoensso/timbre "4.1.0"]
```
## v4.0.2 / 2015 June 26
> This is a minor, non-breaking bug fix release

View File

@ -125,10 +125,9 @@ This is the biggest win over Java logging IMO. Here's `timbre/example-config` (a
:output-fn ; (fn [data]) -> formatted output string
; (see `default-output-fn` for details)
:context ; *context* value at log time (see `with-context`)
:profile-stats ; From `profile` macro
Also incl. any `*context*` keys (see `with-context`).
MIDDLEWARE
Middleware are simple (fn [data]) -> ?data fns (applied left->right) that
transform the data map dispatched to appender fns. If any middleware returns

View File

@ -1,4 +1,4 @@
(defproject com.taoensso/timbre "4.0.2"
(defproject com.taoensso/timbre "4.1.0"
:author "Peter Taoussanis <https://www.taoensso.com>"
:description "Clojure/Script logging & profiling library"
:url "https://github.com/ptaoussanis/timbre"
@ -11,8 +11,8 @@
*assert* true}
:dependencies
[[org.clojure/clojure "1.4.0"]
[com.taoensso/encore "1.37.0"]
[[org.clojure/clojure "1.5.1"]
[com.taoensso/encore "2.4.2"]
[io.aviso/pretty "0.1.18"]]
:plugins
@ -25,9 +25,9 @@
:profiles
{;; :default [:base :system :user :provided :dev]
:server-jvm {:jvm-opts ^:replace ["-server"]}
:1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
:1.7 {:dependencies [[org.clojure/clojure "1.7.0-RC1"]]}
:1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}
:1.8 {:dependencies [[org.clojure/clojure "1.8.0-alpha3"]]}
:test {:dependencies [[expectations "2.1.0"]
[org.clojure/tools.logging "0.3.1"]
@ -38,7 +38,7 @@
[irclj "0.5.0-alpha4"]]}
:dev
[:1.7 :test
{:dependencies [[org.clojure/clojurescript "0.0-3297"]]
{:dependencies [[org.clojure/clojurescript "1.7.28"]]
:plugins
[;; These must be in :dev, Ref. https://github.com/lynaghk/cljx/issues/47:
[com.keminglabs/cljx "0.6.0"]
@ -78,7 +78,7 @@
:aliases
{"test-all" ["do" "clean," "cljx" "once,"
"with-profile" "default:+1.5:+1.6:+1.7" "expectations,"
"with-profile" "default:+1.6:+1.7:+1.8" "expectations,"
"with-profile" "+test" "cljsbuild" "test"]
"test-auto" ["with-profile" "+test" "autoexpect"]
"build-once" ["do" "clean," "cljx" "once," "cljsbuild" "once" "main"]

View File

@ -96,10 +96,9 @@
:output-fn ; (fn [data]) -> formatted output string
; (see `default-output-fn` for details)
:context ; *context* value at log time (see `with-context`)
:profile-stats ; From `profile` macro
Also incl. any `*context*` keys (see `with-context`).
MIDDLEWARE
Middleware are simple (fn [data]) -> ?data fns (applied left->right) that
transform the data map dispatched to appender fns. If any middleware returns
@ -298,8 +297,8 @@
)
(def ^:dynamic *context*
"General-purpose dynamic logging context. Context will be merged into
appender data map at logging time." nil)
"General-purpose dynamic logging context. Context will be included in appender
data map at logging time." nil)
(defmacro with-context [context & body] `(binding [*context* ~context] ~@body))
(declare get-hostname)
@ -327,9 +326,13 @@
vargs*_ (delay (vsplit-err1 (force vargs_)))
?err_ (delay (get @vargs*_ 0))
vargs_ (delay (get @vargs*_ 1))
data (merge ?base-data *context*
context *context*
data (merge ?base-data
;; No, better nest than merge (appenders may want to pass
;; along arb context w/o knowing context keys, etc.):
(when (map? context) context) ; DEPRECATED, for back compat
{:config config ; Entire config!
;; :context *context* ; Extra destructure's a nuisance
:context context
:instant instant
:level level
:?ns-str ?ns-str

View File

@ -1,5 +1,5 @@
(ns taoensso.timbre.appenders.3rd-party.rotor
{:author "Yutaka Matsubara"}
{:author "Karsten Schmidt"}
(:require [clojure.java.io :as io]
[taoensso.timbre :as timbre])
(:import [java.io File FilenameFilter]))

View File

@ -207,32 +207,56 @@
;;;;
(defmacro defnp "Like `defn` but wraps fn bodies with `p` macro."
{:arglists
'([name doc-string? attr-map? [params*] prepost-map? body]
[name doc-string? attr-map? ([params*] prepost-map? body)+ attr-map?])}
[name' & sigs]
(let [[name' sigs] (enc/name-with-attrs name' sigs)
single-arity? (vector? (first sigs))
[sigs func->str]
(if single-arity?
[(list sigs) (fn [name' _params] (name name'))]
[sigs (fn [name' params] (str (name name') \_ (count params)))])
(defn fn-sigs "Implementation detail."
[fn-name sigs]
(let [single-arity? (vector? (first sigs))
sigs (if single-arity? (list sigs) sigs)
get-pid (if single-arity?
(fn [fn-name _params] (name fn-name))
(fn [fn-name params] (str (name fn-name) \_ (count params))))
new-sigs
(map (fn [[params & others]]
(let [has-prepost-map? (and (map? (first others)) (next others))
[prepost-map & body]
(if has-prepost-map?
others
(cons {} others))]
`(~params ~prepost-map (pspy ~(func->str name' params) ~@body))))
(map
(fn [[params & others]]
(let [has-prepost-map? (and (map? (first others)) (next others))
[?prepost-map & body] (if has-prepost-map? others (cons nil others))]
(if ?prepost-map
`(~params ~?prepost-map (pspy ~(get-pid fn-name params) ~@body))
`(~params (pspy ~(get-pid fn-name params) ~@body)))))
sigs)]
`(defn ~name' ~@new-sigs)))
new-sigs))
(defmacro fnp "Like `fn` but wraps fn bodies with `p` macro."
{:arglists '([name? [params*] prepost-map? body]
[name? ([params*] prepost-map? body)+])}
[& sigs]
(let [[?fn-name sigs] (if (symbol? (first sigs))
[(first sigs) (next sigs)]
[nil sigs])
new-sigs (fn-sigs (or ?fn-name 'anonymous-fn) sigs)]
(if ?fn-name
`(fn ~?fn-name ~@new-sigs)
`(fn ~@new-sigs))))
(comment
(defnp foo "Docstring "[x] "boo" (* x x))
(macroexpand '(defnp foo "Docstring" [x] "boo" (* x x)))
(fn-sigs "foo" '([x] (* x x)))
(macroexpand '(fnp [x] (* x x)))
(macroexpand '(fn [x] (* x x)))
(macroexpand '(fnp [x] {:pre [x]} (* x x)))
(macroexpand '(fn [x] {:pre [x]} (* x x))))
(defmacro defnp "Like `defn` but wraps fn bodies with `p` macro."
{:arglists
'([name doc-string? attr-map? [params*] prepost-map? body]
[name doc-string? attr-map? ([params*] prepost-map? body)+ attr-map?])}
[& sigs]
(let [[fn-name sigs] (enc/name-with-attrs (first sigs) (next sigs))
new-sigs (fn-sigs fn-name sigs)]
`(defn ~fn-name ~@new-sigs)))
(comment
(defnp foo "Docstring "[x] (* x x))
(macroexpand '(defnp foo "Docstring" [x] (* x x)))
(macroexpand '(defn foo "Docstring" [x] (* x x)))
(macroexpand '(defnp foo "Docstring" ([x] (* x x))
([x y] (* x y))))
(profile :info :defnp-test (foo 5)))