mirror of
https://github.com/taoensso/telemere.git
synced 2026-01-23 14:59:01 +00:00
[nop] Consistent tools.logging terminology
The terminology is necessarily a bit complex because of competing constraints.
This commit is contained in:
parent
c3ce68b512
commit
8f1035ff97
6 changed files with 28 additions and 21 deletions
|
|
@ -30,7 +30,7 @@ See [here][GitHub releases] for earlier releases.
|
||||||
|
|
||||||
#### Interop
|
#### Interop
|
||||||
|
|
||||||
- 1st-class **out-the-box interop** with [SLF4J v2](https://www.slf4j.org/), [clojure.tools.logging](https://github.com/clojure/tools.logging), [OpenTelemetry](https://opentelemetry.io/), and [Tufte](https://www.taoensso.com/tufte).
|
- 1st-class **out-the-box interop** with [SLF4J v2](https://www.slf4j.org/), [tools.logging](https://github.com/clojure/tools.logging), [OpenTelemetry](https://opentelemetry.io/), and [Tufte](https://www.taoensso.com/tufte).
|
||||||
- Included [shim](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere.timbre) for easy/gradual [migration from Timbre](../../wiki/5-Migrating).
|
- Included [shim](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere.timbre) for easy/gradual [migration from Timbre](../../wiki/5-Migrating).
|
||||||
- Extensive set of [handlers](../../wiki/4-Handlers#included-handlers) included out-the-box.
|
- Extensive set of [handlers](../../wiki/4-Handlers#included-handlers) included out-the-box.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -700,7 +700,7 @@
|
||||||
|
|
||||||
#?(:clj
|
#?(:clj
|
||||||
(defmacro signal-allowed?
|
(defmacro signal-allowed?
|
||||||
"Used only for intake (SLF4J, `clojure.tools.logging`, etc.)."
|
"Used only for intake (SLF4J, `tools.logging`, etc.)."
|
||||||
{:arglists (signal-arglists :signal!)}
|
{:arglists (signal-arglists :signal!)}
|
||||||
[opts]
|
[opts]
|
||||||
(let [{:keys [#_expansion-id #_location elide? allow?]}
|
(let [{:keys [#_expansion-id #_location elide? allow?]}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
(ns taoensso.telemere.tools-logging
|
(ns taoensso.telemere.tools-logging
|
||||||
"Intake support for `clojure.tools.logging` -> Telemere.
|
"Intake support for `tools.logging` -> Telemere.
|
||||||
Telemere will attempt to load this ns automatically when possible."
|
Telemere will attempt to load this ns automatically when possible.
|
||||||
|
|
||||||
|
Naming conventions:
|
||||||
|
`tools.logging` - For referring to the library.
|
||||||
|
`tools-logging` - For symbols, keywords, and this namespace.
|
||||||
|
`clojure.tools.logging` - For env config to match library's conventions."
|
||||||
|
|
||||||
(:require
|
(:require
|
||||||
[taoensso.encore :as enc :refer [have have?]]
|
[taoensso.encore :as enc :refer [have have?]]
|
||||||
[taoensso.telemere.impl :as impl]
|
[taoensso.telemere.impl :as impl]
|
||||||
|
|
@ -12,7 +18,7 @@
|
||||||
|
|
||||||
clojure.tools.logging.impl/Logger
|
clojure.tools.logging.impl/Logger
|
||||||
(enabled? [_ level]
|
(enabled? [_ level]
|
||||||
(when-debug (println [:tools.logger/enabled? logger-ns level]))
|
(when-debug (println [:tools-logging/enabled? logger-ns level]))
|
||||||
(impl/signal-allowed?
|
(impl/signal-allowed?
|
||||||
{:location nil
|
{:location nil
|
||||||
:kind :log
|
:kind :log
|
||||||
|
|
@ -20,7 +26,7 @@
|
||||||
:level level}))
|
:level level}))
|
||||||
|
|
||||||
(write! [_ level throwable message]
|
(write! [_ level throwable message]
|
||||||
(when-debug (println [:tools.logger/write! logger-ns level]))
|
(when-debug (println [:tools-logging/write! logger-ns level]))
|
||||||
(impl/signal!
|
(impl/signal!
|
||||||
{:allow? true ; Pre-filtered by `enabled?` call
|
{:allow? true ; Pre-filtered by `enabled?` call
|
||||||
:location nil
|
:location nil
|
||||||
|
|
@ -37,7 +43,8 @@
|
||||||
(get-logger [_ logger-ns] (TelemereLogger. (str logger-ns))))
|
(get-logger [_ logger-ns] (TelemereLogger. (str logger-ns))))
|
||||||
|
|
||||||
(defn tools-logging->telemere!
|
(defn tools-logging->telemere!
|
||||||
"Configures `clojure.tools.logging` to use Telemere as its logging implementation.
|
"Configures `tools.logging` to use Telemere as its logging
|
||||||
|
implementation (backend).
|
||||||
|
|
||||||
Called automatically if one of the following is \"true\":
|
Called automatically if one of the following is \"true\":
|
||||||
JVM property: `clojure.tools.logging.to-telemere`
|
JVM property: `clojure.tools.logging.to-telemere`
|
||||||
|
|
@ -47,15 +54,15 @@
|
||||||
(impl/signal!
|
(impl/signal!
|
||||||
{:kind :event
|
{:kind :event
|
||||||
:level :info
|
:level :info
|
||||||
:id :taoensso.telemere/clojure.tools.logging->telemere!
|
:id :taoensso.telemere/tools-logging->telemere!
|
||||||
:msg "Enabling intake: `clojure.tools.logging` -> Telemere"})
|
:msg "Enabling intake: `tools.logging` -> Telemere"})
|
||||||
|
|
||||||
(alter-var-root #'clojure.tools.logging/*logger-factory*
|
(alter-var-root #'clojure.tools.logging/*logger-factory*
|
||||||
(fn [_] (TelemereLoggerFactory.))))
|
(fn [_] (TelemereLoggerFactory.))))
|
||||||
|
|
||||||
(defn tools-logging->telemere?
|
(defn tools-logging->telemere?
|
||||||
"Returns true iff `clojure.tools.logging` is configured to use Telemere
|
"Returns true iff `tools.logging` is configured to use Telemere
|
||||||
as its logging implementation."
|
as its logging implementation (backend)."
|
||||||
[]
|
[]
|
||||||
(when-let [lf clojure.tools.logging/*logger-factory*]
|
(when-let [lf clojure.tools.logging/*logger-factory*]
|
||||||
(instance? TelemereLoggerFactory lf)))
|
(instance? TelemereLoggerFactory lf)))
|
||||||
|
|
@ -68,7 +75,7 @@
|
||||||
(let [sending? (tools-logging->telemere?)
|
(let [sending? (tools-logging->telemere?)
|
||||||
receiving?
|
receiving?
|
||||||
(and sending?
|
(and sending?
|
||||||
(impl/test-intake! "`clojure.tools.logging` -> Telemere"
|
(impl/test-intake! "`tools.logging` -> Telemere"
|
||||||
#(clojure.tools.logging/info %)))]
|
#(clojure.tools.logging/info %)))]
|
||||||
|
|
||||||
{:present? true
|
{:present? true
|
||||||
|
|
|
||||||
|
|
@ -580,7 +580,7 @@
|
||||||
|
|
||||||
#?(:clj
|
#?(:clj
|
||||||
(deftest _intake
|
(deftest _intake
|
||||||
[(testing "`clojure.tools.logging` -> Telemere"
|
[(testing "`tools.logging` -> Telemere"
|
||||||
[(is (sm? (tel/check-intakes) {:tools-logging {:present? true, :sending->telemere? true, :telemere-receiving? true}}))
|
[(is (sm? (tel/check-intakes) {:tools-logging {:present? true, :sending->telemere? true, :telemere-receiving? true}}))
|
||||||
|
|
||||||
(is (sm? (with-sig (ctl/info "Hello" "x" "y")) {:level :info, :location nil, :ns nil, :kind :log, :id :taoensso.telemere/tools-logging, :msg_ "Hello x y", :inst pinst?}))
|
(is (sm? (with-sig (ctl/info "Hello" "x" "y")) {:level :info, :location nil, :ns nil, :kind :log, :id :taoensso.telemere/tools-logging, :msg_ "Hello x y", :inst pinst?}))
|
||||||
|
|
|
||||||
|
|
@ -104,11 +104,11 @@ See section [3-Config](./3-Config) for customization.
|
||||||
|
|
||||||
> Telemere can create signals from relevant **external API calls**, etc.
|
> Telemere can create signals from relevant **external API calls**, etc.
|
||||||
|
|
||||||
| Platform | Condition | Signals from |
|
| Platform | Condition | Signals from |
|
||||||
| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
|
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------ |
|
||||||
| Clj | [SLF4J API](https://mvnrepository.com/artifact/org.slf4j/slf4j-api) and [Telemere SLF4J backend](https://clojars.org/com.taoensso/slf4j-telemere) present | [SLF4J](https://www.slf4j.org/) logging calls. |
|
| Clj | [SLF4J API](https://mvnrepository.com/artifact/org.slf4j/slf4j-api) and [Telemere SLF4J backend](https://clojars.org/com.taoensso/slf4j-telemere) present | [SLF4J](https://www.slf4j.org/) logging calls. |
|
||||||
| Clj | [clojure.tools.logging](https://mvnrepository.com/artifact/org.clojure/tools.logging) present and [`tools-logging->telemere!`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere.tools-logging#tools-logging-%3Etelemere!) called | [clojure.tools.logging](https://github.com/clojure/tools.logging) logging calls. |
|
| Clj | [tools.logging](https://mvnrepository.com/artifact/org.clojure/tools.logging) present and [`tools-logging->telemere!`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere.tools-logging#tools-logging-%3Etelemere!) called | [tools.logging](https://github.com/clojure/tools.logging) logging calls. |
|
||||||
| Clj | [`streams->telemere!`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere#streams-%3Etelemere!) called | Output to `System/out` and `System/err` streams. |
|
| Clj | [`streams->telemere!`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere#streams-%3Etelemere!) called | Output to `System/out` and `System/err` streams. |
|
||||||
|
|
||||||
Run [`check-intakes`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere#check-intakes) to help verify/debug:
|
Run [`check-intakes`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere#check-intakes) to help verify/debug:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,13 @@ See section [4-Handlers](./4-Handlers).
|
||||||
|
|
||||||
# Interop
|
# Interop
|
||||||
|
|
||||||
## clojure.tools.logging
|
## tools.logging
|
||||||
|
|
||||||
[`clojure.tools.logging`](https://github.com/clojure/tools.logging) can use Telemere as its logging implementation.
|
[`tools.logging`](https://github.com/clojure/tools.logging) can use Telemere as its logging implementation (backend).
|
||||||
|
|
||||||
To do this:
|
To do this:
|
||||||
|
|
||||||
1. Ensure that you have the `clojure.tools.logging` dependency, and
|
1. Ensure that you have the `tools.logging` dependency, and
|
||||||
2. Call [`tools-logging->telemere!`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere.tools-logging#tools-logging-%3Etelemere!), or set the relevant environmental config as described in its docstring.
|
2. Call [`tools-logging->telemere!`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere.tools-logging#tools-logging-%3Etelemere!), or set the relevant environmental config as described in its docstring.
|
||||||
|
|
||||||
Verify successful intake with [`check-intakes`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere#check-intakes):
|
Verify successful intake with [`check-intakes`](https://cljdoc.org/d/com.taoensso/telemere/CURRENT/api/taoensso.telemere#check-intakes):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue