This commit is contained in:
Peter Taoussanis 2015-05-28 14:02:12 +07:00
parent e5f3e6596f
commit e650148d26
5 changed files with 25 additions and 21 deletions

View File

@ -1,4 +1,4 @@
(ns taoensso.timbre.appenders.3rd-party.android
(ns taoensso.timbre.appenders.3rd-party.android-logcat
"Android LogCat appender. Requires Android runtime."
{:author "Adam Clements"}
(:require [clojure.string :as str]
@ -6,7 +6,7 @@
;; TODO Test port to Timbre v4
(defn logcat-appender
(defn android-logcat-appender
"Returns an appender that writes to Android LogCat. Obviously only works if
running within the Android runtime (device or emulator). You may want to
disable std-out to prevent printing nested timestamps, etc."
@ -52,6 +52,6 @@
;;;; Deprecated
(defn make-logcat-appender
"DEPRECATED. Please use `logcat-appender` instead."
"DEPRECATED. Please use `android-logcat-appender` instead."
[& [appender-merge opts]]
(merge (logcat-appender opts) appender-merge))
(merge (android-logcat-appender opts) appender-merge))

View File

@ -1,4 +1,4 @@
(ns taoensso.timbre.appenders.3rd-party.mongo
(ns taoensso.timbre.appenders.3rd-party.congomongo
"MongoDB appender. Requires on https://github.com/aboekhoff/congomongo."
{:author "Emlyn Corrin"}
(:require [somnium.congomongo :as mongo]

View File

@ -1,4 +1,4 @@
(ns taoensso.timbre.appenders.3rd-party.irc
(ns taoensso.timbre.appenders.3rd-party.irclj
"IRC appender. Requires https://github.com/flatland/irclj."
{:author "Emlyn Corrin"}
(:require [clojure.string :as str]
@ -27,7 +27,7 @@
;;;; Public
(defn irc-appender
(defn irclj-appender
"Returns an IRC appender.
(irc-appender
{:host \"irc.example.org\" :port 6667 :nick \"logger\"
@ -60,15 +60,15 @@
;;;; Deprecated
(defn make-irc-appender
"DEPRECATED. Please use `irc-appender` instead."
"DEPRECATED. Please use `irclj-appender` instead."
[& [appender-merge opts]]
(merge (irc-appender (:irc-config opts) (dissoc :irc-config opts))
(merge (irclj-appender (:irc-config opts) (dissoc :irc-config opts))
appender-merge))
;;;;
(comment
(timbre/merge-config! {:appenders {:irc (irc-appender)}})
(timbre/merge-config! {:appenders {:irc (irclj-appender)}})
(timbre/merge-config!
{:appenders
{:irc

View File

@ -1,4 +1,4 @@
(ns taoensso.timbre.appenders.3rd-party.socket
(ns taoensso.timbre.appenders.3rd-party.server-socket
"TCP socket appender. Requires https://github.com/technomancy/server-socket."
{:author "Emlyn Corrin"}
(:require [server.socket :refer [create-server]]
@ -30,7 +30,7 @@
(defn ensure-conn [socket-config] (swap! conn #(or % (connect socket-config))))
(defn socket-appender
(defn server-socket-appender
"Returns a TCP socket appender.
(socket-appender {:listener-addr :all :port 9000})"
[& [socket-config]]
@ -55,6 +55,6 @@
;;;; Deprecated
(defn make-socket-appender
"DEPRECATED. Please use `socket-appender` instead."
"DEPRECATED. Please use `server-socket-appender` instead."
[& [appender-merge opts]]
(merge (socket-appender opts) appender-merge))
(merge (server-socket-appender opts) appender-merge))

View File

@ -31,7 +31,7 @@
[100 (enc/ms :hours 1)] ; 100 calls/hour
]
:output-fn :inherit ; or (fn [data]) -> string
:output-fn :inherit ; or a custom (fn [data]) -> string
:fn
(fn [data]
(let [;; See `timbre/example-config` for info on all available args:
@ -47,9 +47,13 @@
;; You'll often want an output string with ns, timestamp, vargs, etc.
;; A (fn [data]) -> string formatter is provided under the :output-fn
;; key. Prefer using this fn to your own formatter when possible,
;; since the user can configure the :output-fn formatter in a
;; standard way that'll influence all participating appenders. See
;; key, defined as:
;; `(or (:output-fn <this appender's map>)
;; (:output-fn <user's config map)
;; timbre/default-output-fn)`
;;
;; Users therefore get a standardized way to control appender ouput
;; formatting for all participating appenders. See
;; `taoensso.timbre/default-output-fn` source for details.
;;
output-str (output-fn data)]
@ -133,9 +137,9 @@
"Returns a simple js/console appender for ClojureScript, or nil if no
js/console exists."
[]
(when-let [have-logger? (and (exists? js/console) (.-log js/console))]
(let [have-warn-logger? (and have-logger? (.-warn js/console))
have-error-logger? (and have-logger? (.-error js/console))
(when-let [have-logger? (and (exists? js/console) (.-log js/console))]
(let [have-warn-logger? (.-warn js/console)
have-error-logger? (.-error js/console)
level->logger {:fatal (if have-error-logger? :error :info)
:error (if have-error-logger? :error :info)
:warn (if have-warn-logger? :warn :info)}]