diff --git a/index.clj.html b/index.clj.html index b761950..df97b6c 100644 --- a/index.clj.html +++ b/index.clj.html @@ -1,7 +1,7 @@ -Telemere 1.0.0-beta5

Telemere 1.0.0-beta5

Released under the Eclipse Public License - v 1.0

Structured telemetry library for Clojure/Script.

Installation

To install, add the following dependency to your project or build file:

[com.taoensso/telemere "1.0.0-beta5"]

Namespaces

taoensso.telemere

Structured telemetry for Clojure/Script applications.

taoensso.telemere.open-telemetry

OpenTelemetry handler using `opentelemetry-java`,
+Telemere 1.0.0-beta7

Telemere 1.0.0-beta7

Released under the Eclipse Public License - v 1.0

Structured telemetry library for Clojure/Script.

Installation

To install, add the following dependency to your project or build file:

[com.taoensso/telemere "1.0.0-beta7"]

Namespaces

taoensso.telemere.postal

Email handler using `postal`,
-Ref. <https://github.com/drewr/postal>.

taoensso.telemere.timbre

Main Timbre macros, reimplemented on top of Telemere.
+Ref. <https://github.com/drewr/postal>.

Public variables and functions:

taoensso.telemere.tools-logging

Intake support for `clojure.tools.logging` -> Telemere.
-Telemere will attempt to load this ns automatically when possible.
\ No newline at end of file +Telemere will attempt to load this ns automatically when possible.

taoensso.telemere.utils

Misc utils useful for Telemere handlers, middleware, etc.
\ No newline at end of file diff --git a/index.cljs.html b/index.cljs.html index a22f482..f98fc72 100644 --- a/index.cljs.html +++ b/index.cljs.html @@ -1,4 +1,4 @@ -Telemere 1.0.0-beta5

Telemere 1.0.0-beta5

Released under the Eclipse Public License - v 1.0

Structured telemetry library for Clojure/Script.

Installation

To install, add the following dependency to your project or build file:

[com.taoensso/telemere "1.0.0-beta5"]

Namespaces

taoensso.telemere

Structured telemetry for Clojure/Script applications.

taoensso.telemere.timbre

Main Timbre macros, reimplemented on top of Telemere.
-Intended to help ease migration from Timbre to Telemere.

Public variables and functions:

taoensso.telemere.utils

Misc utils useful for Telemere handlers, middleware, etc.
\ No newline at end of file +Telemere 1.0.0-beta7

Telemere 1.0.0-beta7

Released under the Eclipse Public License - v 1.0

Structured telemetry library for Clojure/Script.

Installation

To install, add the following dependency to your project or build file:

[com.taoensso/telemere "1.0.0-beta7"]

Namespaces

taoensso.telemere

Structured telemetry for Clojure/Script applications.

taoensso.telemere.timbre

Main Timbre macros, reimplemented on top of Telemere.
+Intended to help ease migration from Timbre to Telemere.

Public variables and functions:

taoensso.telemere.utils

Misc utils useful for Telemere handlers, middleware, etc.
\ No newline at end of file diff --git a/index.html b/index.html index cfbbdb6..275bd0d 100644 --- a/index.html +++ b/index.html @@ -1,3 +1,3 @@ -Telemere 1.0.0-beta5

Telemere 1.0.0-beta5

Released under the Eclipse Public License - v 1.0

Structured telemetry library for Clojure/Script.

Installation

To install, add the following dependency to your project or build file:

[com.taoensso/telemere "1.0.0-beta5"]

Platforms

This project includes code for multiple platforms, please choose a platform to view its documentation:

\ No newline at end of file +Telemere 1.0.0-beta7

Telemere 1.0.0-beta7

Released under the Eclipse Public License - v 1.0

Structured telemetry library for Clojure/Script.

Installation

To install, add the following dependency to your project or build file:

[com.taoensso/telemere "1.0.0-beta7"]

Platforms

This project includes code for multiple platforms, please choose a platform to view its documentation:

\ No newline at end of file diff --git a/taoensso.telemere.cljs.html b/taoensso.telemere.cljs.html index c95dec1..71ae315 100644 --- a/taoensso.telemere.cljs.html +++ b/taoensso.telemere.cljs.html @@ -1,6 +1,6 @@ -taoensso.telemere documentation

taoensso.telemere

Structured telemetry for Clojure/Script applications.
+taoensso.telemere documentation

taoensso.telemere

Structured telemetry for Clojure/Script applications.
 
 See the GitHub page (esp. Wiki) for info on motivation and design:
   <https://www.taoensso.com/telemere>

*ctx*

dynamic

clj

cljs

Dynamic context: arbitrary user-level state attached as `:ctx` to all signals.
@@ -15,11 +15,10 @@ when using futures, agents, etc.
 
 Tips:
   - Value may be (or may contain) an atom if you want mutable semantics
-  - Value may be of form {<scope-id> <data>} for custom scoping, etc.

*middleware*

dynamic

clj

cljs

Optional vector of unary middleware fns to apply (sequentially/left-to-right)
-to each signal before passing it to handlers. If any middleware fn returns nil,
-aborts immediately without calling handlers.
+  - Value may be of form {<scope-id> <data>} for custom scoping, etc.

*middleware*

dynamic

clj

cljs

Optional (fn [signal]) => ?modified-signal to apply (once) when
+signal is created. When middleware returns nil, skips all handlers.
 
-Useful for transforming each signal before handling.
+Compose multiple middleware fns together with `comp-middleware.
 
 Re/bind dynamic     value using `with-middleware`, `binding`.
 Modify  root (base) value using `set-middleware!`.

add-handler!

clj

cljs

(add-handler! handler-id handler-fn)(add-handler! handler-id handler-fn dispatch-opts)
Registers given signal handler and returns
@@ -94,11 +93,10 @@ Dispatch options include:
                                and 10 calls per 60   secs
 
   `middleware`
-    Optional vector of unary middleware fns to apply (left-to-right/sequentially)
-    to `handler-arg` before passing to `handler-fn`. If any middleware fn returns
-    nil, aborts immediately without calling `handler-fn`.
+    Optional (fn [handler-arg]) => ?modified-handler-arg to apply before
+    handling. When middleware returns nil, skips handler.
 
-    Useful for transforming `handler-arg` before handling.
+    Compose multiple middleware fns together with `comp-middleware`.
 
   `error-fn` - (fn [{:keys [handler-id handler-arg error]}]) to call on handler error.
   `backp-fn` - (fn [{:keys [handler-id                  ]}]) to call on handler back-pressure.
@@ -157,7 +155,14 @@ See also `error!`.
 [2] See `help:signal-options`  - {:keys [kind level id data ...]}
 [3] See `help:signal-content`  - {:keys [kind level id data ...]}
 [4] See `help:signal-flow`     - (filters, handling, etc.)

chance

clj

cljs

(chance prob)
Returns true with given probability ∈ ℝ[0,1].
-

default-ctx

clj

cljs

Default root (base) value of `*ctx*` var.
+

comp-middleware

clj

cljs

added in Encore v3.106.0 (2024-05-01)

(comp-middleware fs)(comp-middleware f1 f2)(comp-middleware f1 f2 f3)(comp-middleware f1 f2 f3 & fs)
Returns a single (composite) unary fn that applies all given unary fns
+sequentially (left->right!: f1, f2, ...). If any given fn returns nil, the
+returned composite fn immediately returns nil:
+
+  ((comp-middleware inc #(* % 2) inc) 1) => 5 ; (inc (* (inc 1) 2))
+  ((comp-middleware inc (fn [_] nil) (fn [_] (throw (Exception. "Never thrown!")))) 1) => nil
+
+Useful for composing Ring-style middleware fns.

default-ctx

clj

cljs

Default root (base) value of `*ctx*` var.
 Defaults to `nil`, controlled by:
   (get-env {:as :edn} :taoensso.telemere/default-ctx<.platform><.edn>)
 
@@ -228,7 +233,12 @@ Tips:
 [1] See `help:signal-creators` - (`signal!`, `log!`, `event!`, ...)
 [2] See `help:signal-options`  - {:keys [kind level id data ...]}
 [3] See `help:signal-content`  - {:keys [kind level id data ...]}
-[4] See `help:signal-flow`     - (filters, handling, etc.)

get-env

macro

clj

cljs

added in Encore v3.75.0 (2024-01-29)

(get-env {:keys [as default return], :or {as :str, return :value}} spec)
Flexible cross-platform util for embedding a config value during
+[4] See `help:signal-flow`     - (filters, handling, etc.)

format-signal-fn

clj

cljs

(format-signal-fn)(format-signal-fn {:keys [incl-newline? preamble-fn content-fn], :or {incl-newline? true, preamble-fn (signal-preamble-fn), content-fn (signal-content-fn)}})
Experimental, subject to change.
+Returns a (fn format [signal]) that:
+  - Takes a Telemere signal.
+  - Returns human-readable formatted string.
+
+See also `pr-signal-fn` for machine-readable output.

get-env

macro

clj

cljs

added in Encore v3.75.0 (2024-01-29)

(get-env {:keys [as default return], :or {as :str, return :value}} spec)
Flexible cross-platform util for embedding a config value during
 macro expansion. Used by other Taoensso libraries.
 
 Given a const kw/string id or vector of desc-priority alternative ids,
@@ -283,17 +293,17 @@ TIP!: Use the {:return :explain} option in tests or at the REPL to verify/inspec
 resulting config value, config source, and specific search order of prop/env/res ids.

get-filters

clj

cljs

(get-filters)
Returns current ?{:keys [compile-time runtime]} filter config.
 

get-handlers

clj

cljs

(get-handlers)
Returns ?{<handler-id> {:keys [dispatch-opts handler-fn]}} for all
 registered signal handlers.

get-min-level

clj

cljs

(get-min-level)(get-min-level kind)(get-min-level kind ns)
Returns current ?{:keys [compile-time runtime]} minimum levels.
-

handler:console

clj

cljs

(handler:console)(handler:console {:keys [format-signal-fn], :or {format-signal-fn (utils/format-signal->str-fn)}})
Experimental, subject to change. Feedback welcome!
+

handler:console

clj

cljs

(handler:console)(handler:console {:keys [output-fn], :or {output-fn (utils/format-signal-fn)}})
Experimental, subject to change. Feedback welcome!
 
 If `js/console` exists, returns a (fn handler [signal]) that:
   - Takes a Telemere signal.
-  - Writes a formatted signal string to JavaScript console.
+  - Writes formatted signal string to JavaScript console.
 
 A general-purpose `println`-style handler that's well suited for outputting
 signals formatted as edn, JSON, or human-readable strings.
 
 Options:
-  `:format-signal-fn` - (fn [signal]) => output, see `help:signal-formatters`

handler:console-raw

cljs

(handler:console-raw)(handler:console-raw {:keys [format-signal->prelude-fn format-nsecs-fn], :as opts, :or {format-signal->prelude-fn (utils/format-signal->prelude-fn), format-nsecs-fn (utils/format-nsecs-fn)}})
Experimental, subject to change. Feedback welcome!
+  `:output-fn` - (fn [signal]) => output string, see `format-signal-fn` or `pr-signal-fn`

handler:console-raw

cljs

(handler:console-raw)(handler:console-raw {:keys [preamble-fn format-nsecs-fn], :as opts, :or {preamble-fn (utils/signal-preamble-fn), format-nsecs-fn (utils/format-nsecs-fn)}})
Experimental, subject to change. Feedback welcome!
 
 If `js/console` exists, returns a (fn handler [signal]) that:
   - Takes a Telemere signal.
@@ -421,6 +431,7 @@ Default signal keys:
 `:line` -------- ?int line      of signal creator callsite, same as (:line   location)
 `:column` ------ ?int column    of signal creator callsite, same as (:column location)
 `:file` -------- ?str filename  of signal creator callsite, same as (:file   location)
+`:thread` ------ (Clj only) {:keys [group name id]} thread info for thread that called signal creator
 `:sample-rate` - ?rate ∈ℝ[0,1] for combined signal AND handler sampling (0.75 => allow 75% of signals, nil => allow all)
 
 <kvs> ---------- Other arb user-level ?kvs given to signal creator. Typically NOT included
@@ -509,12 +520,7 @@ For more info:
   - On handler filters, see: `help:signal-handlers` docstring
 
 If anything is unclear, please ping me (@ptaoussanis) so that I can
-improve these docs!

help:signal-formatters

clj

cljs

Common signal formatters include:
-  (utils/format-signal-str->fn) {<opts>}) ; For human-readable string output (default)
-  (utils/format-signal->edn-fn) {<opts>}) ; For edn  output
-  (utils/format-signal->json-fn {<opts>}) ; For JSON output
-
-See relevant docstrings for details.

help:signal-handlers

clj

cljs

help:signal-options

clj

cljs

Signal options (shared by all signal creators):
+improve these docs!

help:signal-handlers

clj

cljs

help:signal-options

clj

cljs

Signal options (shared by all signal creators):
 
 `:inst` -------- Platform instant [1] when signal was created, ∈ #{nil :auto <user-val>}
 `:level` ------- Signal level ∈ #{<int> :trace :debug :info :warn :error :fatal :report ...}
@@ -538,7 +544,7 @@ See relevant docstrings for details.

newline

clj

cljs

added in Encore v3.68.0 (2023-09-25)

Single system newline
-

rate-limiter

clj

cljs

(rate-limiter spec)(rate-limiter opts spec)
Takes a spec of form
+

pr-signal-fn

clj

cljs

(pr-signal-fn pr-fn)(pr-signal-fn pr-fn {:keys [incl-thread? incl-kvs? incl-newline? prep-fn], :or {incl-newline? true, prep-fn (comp error-in-signal->maps minify-signal)}})
Experimental, subject to change.
+Returns a (fn pr-signal [signal]) that:
+  - Takes a Telemere signal.
+  - Returns machine-readable serialized string of the (minified) signal.
+
+Options include:
+  `pr-fn` ∈ #{<unary-fn> :edn :json (Cljs only)}
+  See arglists for more.
+
+Examples:
+  (pr-signal-fn :edn  {<opts>})
+  (pr-signal-fn :json {<opts>}) ; Cljs only
+
+  ;; To output JSON for Clj, you must provide an appropriate `pr-fn`.
+  ;; `jsonista` is a good option, Ref. <https://github.com/metosin/jsonista>:
+    (require '[jsonista.core :as jsonista])
+    (pr-signal-fn jsonista/write-value-as-string {<opts>})
+
+See also `format-signal-fn` for human-readable output.

rate-limiter

clj

cljs

(rate-limiter spec)(rate-limiter opts spec)
Takes a spec of form
   [           [<n-max-reqs> <msecs-window>] ...] or
   {<limit-id> [<n-max-reqs> <msecs-window>]},
 and returns a basic stateful (fn a-rate-limiter [req-id] [command req-id]).
@@ -620,7 +644,7 @@ Example:
       (throw (ex-info "Sorry, rate limited!" {:fail fail}))
       <send message>))

remove-handler!

clj

cljs

(remove-handler! handler-id)
Deregisters signal handler with given id, and returns
 ?{<handler-id> {:keys [dispatch-opts handler-fn]}} for all signal handlers
-still registered.

set-ctx!

macro

clj

cljs

(set-ctx! root-val)
Set `*ctx*` var's root (base) value. See `*ctx*` for details.
+still registered.

set-ctx!

macro

clj

cljs

(set-ctx! root-ctx-val)
Set `*ctx*` var's root (base) value. See `*ctx*` for details.
 

set-id-filter!

clj

cljs

(set-id-filter! id-filter)
Sets signal call id filter based on given `id-filter` spec.
 `id-filter` may be:
 
@@ -637,7 +661,7 @@ still registered.

set-middleware!

macro

clj

cljs

(set-middleware! root-val)
Set `*middleware*` var's root (base) value. See `*middleware*` for details.
+    If present, `:deny`  spec MUST NOT match.

set-middleware!

macro

clj

cljs

(set-middleware! ?root-middleware-fn)
Set `*middleware*` var's root (base) value. See `*middleware*` for details.
 

set-min-level!

clj

cljs

(set-min-level! min-level)(set-min-level! kind min-level)(set-min-level! kind ns-filter min-level)
Sets minimum signal call level based on given `min-level` spec.
 `min-level` may be:
 
@@ -793,7 +817,7 @@ the new value:
   (update-var-root! my-var (fn [old-root-val] <new-root-val>)) => <new-root-val>
 
 Similar to `alter-var-root` but cross-platform and takes a symbol rather than a var.
-See also `set-var-root!`.

with-ctx

macro

clj

cljs

(with-ctx init-val form)
Evaluates given form with given `*ctx*` value. See `*ctx*` for details.
+See also `set-var-root!`.

with-ctx

macro

clj

cljs

(with-ctx ctx-val form)
Evaluates given form with given `*ctx*` value. See `*ctx*` for details.
 

with-ctx+

macro

clj

cljs

(with-ctx+ update-map-or-fn form)
Evaluates given form with updated `*ctx*` value.
 
 `update-map-or-fn` may be:
@@ -805,7 +829,7 @@ See `*ctx*` for details.

with-handler+

macro

clj

cljs

(with-handler+ handler-id handler-fn dispatch-opts form)
Executes form with the given handler-fn registered.
 Useful for tests/debugging. See also `with-handler`.

with-id-filter

macro

clj

cljs

(with-id-filter id-filter form)
Executes form with given signal call id filter in effect.
 See `set-id-filter!` for details.

with-kind-filter

macro

clj

cljs

(with-kind-filter kind-filter form)
Executes form with given signal call kind filter in effect.
-See `set-kind-filter!` for details.

with-middleware

macro

clj

cljs

(with-middleware init-val form)
Evaluates given form with given `*middleware*` value.
+See `set-kind-filter!` for details.

with-middleware

macro

clj

cljs

(with-middleware ?middleware-fn form)
Evaluates given form with given `*middleware*` value.
 See `*middleware*` for details.

with-min-level

macro

clj

cljs

(with-min-level min-level form)(with-min-level kind min-level form)(with-min-level kind ns-filter min-level form)
Executes form with given minimum signal call level in effect.
 See `set-min-level!` for details.

with-ns-filter

macro

clj

cljs

(with-ns-filter ns-filter form)
Executes form with given signal call namespace filter in effect.
 See `set-ns-filter!` for details.

with-out->telemere

macro

clj

cljs

(with-out->telemere form)(with-out->telemere opts form)
Executes form with `*out*` bound to flush to Telemere signals with given opts.
diff --git a/taoensso.telemere.html b/taoensso.telemere.html
index 5ab0757..a9717fe 100644
--- a/taoensso.telemere.html
+++ b/taoensso.telemere.html
@@ -1,6 +1,6 @@
 
-taoensso.telemere documentation

taoensso.telemere

Structured telemetry for Clojure/Script applications.
+taoensso.telemere documentation

taoensso.telemere

Structured telemetry for Clojure/Script applications.
 
 See the GitHub page (esp. Wiki) for info on motivation and design:
   <https://www.taoensso.com/telemere>

*ctx*

dynamic

clj

cljs

Dynamic context: arbitrary user-level state attached as `:ctx` to all signals.
@@ -15,11 +15,10 @@ when using futures, agents, etc.
 
 Tips:
   - Value may be (or may contain) an atom if you want mutable semantics
-  - Value may be of form {<scope-id> <data>} for custom scoping, etc.

*middleware*

dynamic

clj

cljs

Optional vector of unary middleware fns to apply (sequentially/left-to-right)
-to each signal before passing it to handlers. If any middleware fn returns nil,
-aborts immediately without calling handlers.
+  - Value may be of form {<scope-id> <data>} for custom scoping, etc.

*middleware*

dynamic

clj

cljs

Optional (fn [signal]) => ?modified-signal to apply (once) when
+signal is created. When middleware returns nil, skips all handlers.
 
-Useful for transforming each signal before handling.
+Compose multiple middleware fns together with `comp-middleware.
 
 Re/bind dynamic     value using `with-middleware`, `binding`.
 Modify  root (base) value using `set-middleware!`.

add-handler!

clj

cljs

(add-handler! handler-id handler-fn)(add-handler! handler-id handler-fn dispatch-opts)
Registers given signal handler and returns
@@ -94,11 +93,10 @@ Dispatch options include:
                                and 10 calls per 60   secs
 
   `middleware`
-    Optional vector of unary middleware fns to apply (left-to-right/sequentially)
-    to `handler-arg` before passing to `handler-fn`. If any middleware fn returns
-    nil, aborts immediately without calling `handler-fn`.
+    Optional (fn [handler-arg]) => ?modified-handler-arg to apply before
+    handling. When middleware returns nil, skips handler.
 
-    Useful for transforming `handler-arg` before handling.
+    Compose multiple middleware fns together with `comp-middleware`.
 
   `error-fn` - (fn [{:keys [handler-id handler-arg error]}]) to call on handler error.
   `backp-fn` - (fn [{:keys [handler-id                  ]}]) to call on handler back-pressure.
@@ -161,7 +159,14 @@ See also `error!`.
 Runs Telemere's registered intake checks and returns
 {<source-id> {:keys [sending->telemere? telemere-receiving? ...]}}.
 
-Useful for tests/debugging.

default-ctx

clj

cljs

Default root (base) value of `*ctx*` var.
+Useful for tests/debugging.

comp-middleware

clj

cljs

added in Encore v3.106.0 (2024-05-01)

(comp-middleware fs)(comp-middleware f1 f2)(comp-middleware f1 f2 f3)(comp-middleware f1 f2 f3 & fs)
Returns a single (composite) unary fn that applies all given unary fns
+sequentially (left->right!: f1, f2, ...). If any given fn returns nil, the
+returned composite fn immediately returns nil:
+
+  ((comp-middleware inc #(* % 2) inc) 1) => 5 ; (inc (* (inc 1) 2))
+  ((comp-middleware inc (fn [_] nil) (fn [_] (throw (Exception. "Never thrown!")))) 1) => nil
+
+Useful for composing Ring-style middleware fns.

default-ctx

clj

cljs

Default root (base) value of `*ctx*` var.
 Defaults to `nil`, controlled by:
   (get-env {:as :edn} :taoensso.telemere/default-ctx<.platform><.edn>)
 
@@ -232,7 +237,12 @@ Tips:
 [1] See `help:signal-creators` - (`signal!`, `log!`, `event!`, ...)
 [2] See `help:signal-options`  - {:keys [kind level id data ...]}
 [3] See `help:signal-content`  - {:keys [kind level id data ...]}
-[4] See `help:signal-flow`     - (filters, handling, etc.)

get-env

macro

clj

cljs

added in Encore v3.75.0 (2024-01-29)

(get-env {:keys [as default return], :or {as :str, return :value}} spec)
Flexible cross-platform util for embedding a config value during
+[4] See `help:signal-flow`     - (filters, handling, etc.)

format-signal-fn

clj

cljs

(format-signal-fn)(format-signal-fn {:keys [incl-newline? preamble-fn content-fn], :or {incl-newline? true, preamble-fn (signal-preamble-fn), content-fn (signal-content-fn)}})
Experimental, subject to change.
+Returns a (fn format [signal]) that:
+  - Takes a Telemere signal.
+  - Returns human-readable formatted string.
+
+See also `pr-signal-fn` for machine-readable output.

get-env

macro

clj

cljs

added in Encore v3.75.0 (2024-01-29)

(get-env {:keys [as default return], :or {as :str, return :value}} spec)
Flexible cross-platform util for embedding a config value during
 macro expansion. Used by other Taoensso libraries.
 
 Given a const kw/string id or vector of desc-priority alternative ids,
@@ -287,24 +297,23 @@ TIP!: Use the {:return :explain} option in tests or at the REPL to verify/inspec
 resulting config value, config source, and specific search order of prop/env/res ids.

get-filters

clj

cljs

(get-filters)
Returns current ?{:keys [compile-time runtime]} filter config.
 

get-handlers

clj

cljs

(get-handlers)
Returns ?{<handler-id> {:keys [dispatch-opts handler-fn]}} for all
 registered signal handlers.

get-min-level

clj

cljs

(get-min-level)(get-min-level kind)(get-min-level kind ns)
Returns current ?{:keys [compile-time runtime]} minimum levels.
-

handler:console

clj

cljs

(handler:console)(handler:console {:keys [format-signal-fn stream], :or {format-signal-fn (utils/format-signal->str-fn)}})
Experimental, subject to change. Feedback welcome!
+

handler:console

clj

cljs

(handler:console)(handler:console {:keys [output-fn stream], :or {output-fn (utils/format-signal-fn)}})
Experimental, subject to change. Feedback welcome!
 
 Returns a (fn handler [signal]) that:
   - Takes a Telemere signal.
-  - Writes a formatted signal string to stream.
+  - Writes formatted signal string to stream.
 
 A general-purpose `println`-style handler that's well suited for outputting
 signals formatted as edn, JSON, or human-readable strings.
 
 Options:
-  `:format-signal-fn` - (fn [signal]) => output, see `help:signal-formatters`
-
-  `:stream` - `java.io.writer`
-    Defaults to `*err*` if `utils/error-signal?` is true, and `*out*` otherwise.

handler:file

clj

(handler:file)(handler:file {:keys [format-signal-fn path interval max-file-size max-num-parts max-num-intervals gzip-archives?], :or {format-signal-fn (utils/format-signal->str-fn), path "logs/telemere.log", interval :monthly, max-file-size (* 1024 1024 4), max-num-parts 8, max-num-intervals 6, gzip-archives? true}})
Experimental, subject to change. Feedback welcome!
+  `:output-fn` - (fn [signal]) => output string, see `format-signal-fn` or `pr-signal-fn`
+  `:stream`    - `java.io.writer`
+    Defaults to `*err*` if `utils/error-signal?` is true, and `*out*` otherwise.

handler:file

clj

(handler:file)(handler:file {:keys [output-fn path interval max-file-size max-num-parts max-num-intervals gzip-archives?], :or {output-fn (utils/format-signal-fn), path "logs/telemere.log", interval :monthly, max-file-size (* 1024 1024 4), max-num-parts 8, max-num-intervals 6, gzip-archives? true}})
Experimental, subject to change. Feedback welcome!
 
    Returns a (fn handler [signal]) that:
      - Takes a Telemere signal.
-     - Writes a formatted signal string to file.
+     - Writes formatted signal string to file.
 
 Signals will be appended to file specified by `path`.
 Depending on options, archives may be maintained:
@@ -318,9 +327,10 @@ Example files with default options:
   `/logs/telemere.log-2020-01-01m.8.gz` ; Archive for Jan 2020, part 8 (oldest entries)
 
 Options:
-  `:format-signal-fn`- (fn [signal])  => output, see `help:signal-formatters`.
-  `:path` - Path string of the target output file (default `logs/telemere.log`).
-  `:interval` - ∈ #{nil :daily :weekly :monthly} (default `:monthly`).
+  `:output-fn`- (fn [signal])  => output string, see `format-signal-fn` or `pr-signal-fn`
+  `:path`     - Path string of the target output file (default `logs/telemere.log`)
+
+  `:interval` - ∈ #{nil :daily :weekly :monthly} (default `:monthly`)
     When non-nil, causes interval-based archives to be maintained.
 
   `:max-file-size` ∈ #{nil <pos-int>} (default 4MB)
@@ -451,6 +461,7 @@ Default signal keys:
 `:line` -------- ?int line      of signal creator callsite, same as (:line   location)
 `:column` ------ ?int column    of signal creator callsite, same as (:column location)
 `:file` -------- ?str filename  of signal creator callsite, same as (:file   location)
+`:thread` ------ (Clj only) {:keys [group name id]} thread info for thread that called signal creator
 `:sample-rate` - ?rate ∈ℝ[0,1] for combined signal AND handler sampling (0.75 => allow 75% of signals, nil => allow all)
 
 <kvs> ---------- Other arb user-level ?kvs given to signal creator. Typically NOT included
@@ -620,12 +631,7 @@ For more info:
   - On handler filters, see: `help:signal-handlers` docstring
 
 If anything is unclear, please ping me (@ptaoussanis) so that I can
-improve these docs!

help:signal-formatters

clj

cljs

Common signal formatters include:
-  (utils/format-signal-str->fn) {<opts>}) ; For human-readable string output (default)
-  (utils/format-signal->edn-fn) {<opts>}) ; For edn  output
-  (utils/format-signal->json-fn {<opts>}) ; For JSON output
-
-See relevant docstrings for details.

help:signal-handlers

clj

cljs

Manage handlers with:
+improve these docs!

help:signal-handlers

clj

cljs

Manage handlers with:
 
   `get-handlers`        - Returns info on registered handlers
   `shut-down-handlers!` - Shuts down      registered handlers
@@ -661,7 +667,7 @@ improve these docs!

newline

clj

cljs

added in Encore v3.68.0 (2023-09-25)

Single system newline
-

rate-limiter

clj

cljs

(rate-limiter spec)(rate-limiter opts spec)
Takes a spec of form
+

pr-signal-fn

clj

cljs

(pr-signal-fn pr-fn)(pr-signal-fn pr-fn {:keys [incl-thread? incl-kvs? incl-newline? prep-fn], :or {incl-newline? true, prep-fn (comp error-in-signal->maps minify-signal)}})
Experimental, subject to change.
+Returns a (fn pr-signal [signal]) that:
+  - Takes a Telemere signal.
+  - Returns machine-readable serialized string of the (minified) signal.
+
+Options include:
+  `pr-fn` ∈ #{<unary-fn> :edn :json (Cljs only)}
+  See arglists for more.
+
+Examples:
+  (pr-signal-fn :edn  {<opts>})
+  (pr-signal-fn :json {<opts>}) ; Cljs only
+
+  ;; To output JSON for Clj, you must provide an appropriate `pr-fn`.
+  ;; `jsonista` is a good option, Ref. <https://github.com/metosin/jsonista>:
+    (require '[jsonista.core :as jsonista])
+    (pr-signal-fn jsonista/write-value-as-string {<opts>})
+
+See also `format-signal-fn` for human-readable output.

rate-limiter

clj

cljs

(rate-limiter spec)(rate-limiter opts spec)
Takes a spec of form
   [           [<n-max-reqs> <msecs-window>] ...] or
   {<limit-id> [<n-max-reqs> <msecs-window>]},
 and returns a basic stateful (fn a-rate-limiter [req-id] [command req-id]).
@@ -751,7 +775,7 @@ Example:
       (throw (ex-info "Sorry, rate limited!" {:fail fail}))
       <send message>))

remove-handler!

clj

cljs

(remove-handler! handler-id)
Deregisters signal handler with given id, and returns
 ?{<handler-id> {:keys [dispatch-opts handler-fn]}} for all signal handlers
-still registered.

set-ctx!

macro

clj

cljs

(set-ctx! root-val)
Set `*ctx*` var's root (base) value. See `*ctx*` for details.
+still registered.

set-ctx!

macro

clj

cljs

(set-ctx! root-ctx-val)
Set `*ctx*` var's root (base) value. See `*ctx*` for details.
 

set-id-filter!

clj

cljs

(set-id-filter! id-filter)
Sets signal call id filter based on given `id-filter` spec.
 `id-filter` may be:
 
@@ -768,7 +792,7 @@ still registered.

set-middleware!

macro

clj

cljs

(set-middleware! root-val)
Set `*middleware*` var's root (base) value. See `*middleware*` for details.
+    If present, `:deny`  spec MUST NOT match.

set-middleware!

macro

clj

cljs

(set-middleware! ?root-middleware-fn)
Set `*middleware*` var's root (base) value. See `*middleware*` for details.
 

set-min-level!

clj

cljs

(set-min-level! min-level)(set-min-level! kind min-level)(set-min-level! kind ns-filter min-level)
Sets minimum signal call level based on given `min-level` spec.
 `min-level` may be:
 
@@ -801,7 +825,7 @@ Examples:
   - {:allow <spec> :deny <spec>} with specs as above.
     If present, `:allow` spec MUST     match, AND
     If present, `:deny`  spec MUST NOT match.

set-var-root!

macro

clj

cljs

added in Encore v3.75.0 (2024-01-29)

(set-var-root! var-sym root-val)
Sets root binding (value) of the var identified by given symbol, and returns
-the new value. Cross-platform. See also `update-var-root!`.

shut-down-handlers!

clj

cljs

(shut-down-handlers!)(shut-down-handlers! timeout-msecs__9349__auto__)
Shuts down all registered signal handlers in parallel, and returns
+the new value. Cross-platform. See also `update-var-root!`.

shut-down-handlers!

clj

cljs

(shut-down-handlers!)(shut-down-handlers! timeout-msecs__8468__auto__)
Shuts down all registered signal handlers in parallel, and returns
 ?{<handler-id> {:keys [okay error]}}.
 
 Future calls to handlers will no-op.
@@ -940,7 +964,7 @@ the new value:
   (update-var-root! my-var (fn [old-root-val] <new-root-val>)) => <new-root-val>
 
 Similar to `alter-var-root` but cross-platform and takes a symbol rather than a var.
-See also `set-var-root!`.

with-ctx

macro

clj

cljs

(with-ctx init-val form)
Evaluates given form with given `*ctx*` value. See `*ctx*` for details.
+See also `set-var-root!`.

with-ctx

macro

clj

cljs

(with-ctx ctx-val form)
Evaluates given form with given `*ctx*` value. See `*ctx*` for details.
 

with-ctx+

macro

clj

cljs

(with-ctx+ update-map-or-fn form)
Evaluates given form with updated `*ctx*` value.
 
 `update-map-or-fn` may be:
@@ -952,7 +976,7 @@ See `*ctx*` for details.

with-handler+

macro

clj

cljs

(with-handler+ handler-id handler-fn dispatch-opts form)
Executes form with the given handler-fn registered.
 Useful for tests/debugging. See also `with-handler`.

with-id-filter

macro

clj

cljs

(with-id-filter id-filter form)
Executes form with given signal call id filter in effect.
 See `set-id-filter!` for details.

with-kind-filter

macro

clj

cljs

(with-kind-filter kind-filter form)
Executes form with given signal call kind filter in effect.
-See `set-kind-filter!` for details.

with-middleware

macro

clj

cljs

(with-middleware init-val form)
Evaluates given form with given `*middleware*` value.
+See `set-kind-filter!` for details.

with-middleware

macro

clj

cljs

(with-middleware ?middleware-fn form)
Evaluates given form with given `*middleware*` value.
 See `*middleware*` for details.

with-min-level

macro

clj

cljs

(with-min-level min-level form)(with-min-level kind min-level form)(with-min-level kind ns-filter min-level form)
Executes form with given minimum signal call level in effect.
 See `set-min-level!` for details.

with-ns-filter

macro

clj

cljs

(with-ns-filter ns-filter form)
Executes form with given signal call namespace filter in effect.
 See `set-ns-filter!` for details.

with-out->telemere

macro

clj

cljs

(with-out->telemere form)(with-out->telemere opts form)
Executes form with `*out*` bound to flush to Telemere signals with given opts.
diff --git a/taoensso.telemere.open-telemetry.html b/taoensso.telemere.open-telemetry.html
index c1759a7..2150a11 100644
--- a/taoensso.telemere.open-telemetry.html
+++ b/taoensso.telemere.open-telemetry.html
@@ -1,6 +1,6 @@
 
-taoensso.telemere.open-telemetry documentation

taoensso.telemere.open-telemetry

OpenTelemetry handler using `opentelemetry-java`,
+taoensso.telemere.open-telemetry documentation

taoensso.telemere.open-telemetry

OpenTelemetry handler using `opentelemetry-java`,
 Ref. <https://github.com/open-telemetry/opentelemetry-java>.

default-logger-provider

clj

(default-logger-provider)
Experimental, subject to change. Feedback welcome!
 
 Returns `io.opentelemetry.api.logs.LoggerProvider` via:
diff --git a/taoensso.telemere.postal.html b/taoensso.telemere.postal.html
index 6246abe..ae32762 100644
--- a/taoensso.telemere.postal.html
+++ b/taoensso.telemere.postal.html
@@ -1,18 +1,14 @@
 
-taoensso.telemere.postal documentation

taoensso.telemere.postal

Email handler using `postal`,
-Ref. <https://github.com/drewr/postal>.

a-handler:postal

clj

(a-handler:postal)(a-handler:postal signal)

format-signal->subject-fn

clj

(format-signal->subject-fn)(format-signal->subject-fn {:keys [max-len subject-signal-key], :or {max-len 128, subject-signal-key :postal/subject}})
Experimental, subject to change.
-Returns a (fn format [signal]) that:
-  - Takes a Telemere signal.
-  - Returns a formatted email subject like:
-    "INFO EVENT :taoensso.telemere.postal/ev-id1 - msg"

handler:postal

clj

(handler:postal)(handler:postal {:keys [postal/conn-opts postal/msg-opts format-signal-fn format-signal->subject-fn], :or {format-signal-fn (utils/format-signal->str-fn), format-signal->subject-fn (format-signal->subject-fn)}})
Experimental, subject to change. Feedback welcome!
+taoensso.telemere.postal documentation

taoensso.telemere.postal

Email handler using `postal`,
+Ref. <https://github.com/drewr/postal>.

a-handler:postal

clj

(a-handler:postal)(a-handler:postal signal)

handler:postal

clj

(handler:postal)(handler:postal {:keys [postal/conn-opts postal/msg-opts subject-fn body-fn], :or {subject-fn (signal-subject-fn), body-fn (utils/format-signal-fn)}})
Experimental, subject to change. Feedback welcome!
 
 Needs `postal`,
   Ref. <https://github.com/drewr/postal>.
 
 Returns a (fn handler [signal]) that:
   - Takes a Telemere signal.
-  - Sends an email with formatted signal content to the configured recipient.
+  - Sends formatted signal string as email to specified recipient.
 
 Useful for emailing important alerts to admins, etc.
 
@@ -37,8 +33,8 @@ Options:
        :cc "engineering@example.com"
        :X-MyHeader "A custom header"}
 
-  `:format-signal-fn`          - (fn [signal]) => output, see `help:signal-formatters`
-  `:format-signal->subject-fn` - (fn [signal]) => email subject string
+  `:subject-fn` - (fn [signal]) => email subject string
+  `:body-fn`    - (fn [signal]) => email body content string, see `format-signal-fn` or `pr-signal-fn`
 
 Tips:
 
@@ -58,4 +54,8 @@ Tips:
       (add-handler! :my-postal-handler (handler:postal {<my-handler-opts>})
         {:async {:mode :dropping, :buffer-size 128, :n-threads 4} ...}), etc.
 
-  - Ref. <https://github.com/drewr/postal> for more info on `postal` options.
\ No newline at end of file + - Ref. <https://github.com/drewr/postal> for more info on `postal` options.

signal-subject-fn

clj

(signal-subject-fn)(signal-subject-fn {:keys [max-len subject-signal-key], :or {max-len 128, subject-signal-key :postal/subject}})
Experimental, subject to change.
+Returns a (fn format [signal]) that:
+  - Takes a Telemere signal.
+  - Returns a formatted email subject like:
+    "INFO EVENT :taoensso.telemere.postal/ev-id1 - msg"
\ No newline at end of file diff --git a/taoensso.telemere.sockets.html b/taoensso.telemere.sockets.html new file mode 100644 index 0000000..d439924 --- /dev/null +++ b/taoensso.telemere.sockets.html @@ -0,0 +1,41 @@ + +taoensso.telemere.sockets documentation

taoensso.telemere.sockets

Basic TCP/UDP socket handlers.
+

a-handler:tcp-socket

clj

(a-handler:tcp-socket)(a-handler:tcp-socket signal)

a-handler:udp-socket

clj

(a-handler:udp-socket)(a-handler:udp-socket signal)

handler:tcp-socket

clj

(handler:tcp-socket host port)(handler:tcp-socket host port {:keys [socket-opts output-fn], :or {output-fn (utils/format-signal-fn)}})
Experimental, subject to change. Feedback welcome!
+
+Returns a (fn handler [signal]) that:
+  - Takes a Telemere signal.
+  - Sends formatted signal string to specified TCP socket.
+
+Options:
+  `host` - Destination TCP socket hostname string
+  `port` - Destination TCP socket port int
+
+  `:socket-opts` - {:keys [ssl? connect-timeout-msecs]}
+  `:output-fn`   - (fn [signal]) => output string, see `format-signal-fn` or `pr-signal-fn`
+
+Limitations:
+  - Failed writes will be retried only once.
+  - Writes lock on a single underlying socket, so IO won't benefit from adding
+    extra handler threads. Let me know if there's demand for socket pooling.

handler:udp-socket

clj

(handler:udp-socket host port)(handler:udp-socket host port {:keys [output-fn max-packet-bytes truncation-warning-fn], :or {output-fn (utils/format-signal-fn), max-packet-bytes 512}})
Experimental, subject to change. Feedback welcome!
+
+Returns a (fn handler [signal]) that:
+  - Takes a Telemere signal.
+  - Sends formatted signal string to specified UDP socket.
+
+Options:
+  `host` - Destination UDP socket hostname string
+  `port` - Destination UDP socket port int
+
+  `:output-fn`             - (fn [signal]) => output string, see `format-signal-fn` or `pr-signal-fn`
+  `:max-packet-bytes`      - Max packet size (in bytes) before truncating output (default 512)
+  `:truncation-warning-fn` - Optional (fn [{:keys [max actual signal]}]) to call whenever
+                             output is truncated. Should be appropriately rate-limited!
+
+Limitations:
+  - Due to UDP limitations, truncates output to `max-packet-bytes`!
+  - Failed writes will be retried only once.
+  - Writes lock on a single underlying socket, so IO won't benefit from adding
+    extra handler threads. Let me know if there's demand for socket pooling.
+  - No DTLS (Datagram Transport Layer Security) support,
+    please let me know if there's demand.
\ No newline at end of file diff --git a/taoensso.telemere.streams.html b/taoensso.telemere.streams.html index 733faae..6fbd7a2 100644 --- a/taoensso.telemere.streams.html +++ b/taoensso.telemere.streams.html @@ -1,6 +1,6 @@ -taoensso.telemere.streams documentation

taoensso.telemere.streams

Intake support for standard stream/s -> Telemere.
+taoensso.telemere.streams documentation

taoensso.telemere.streams

Intake support for standard stream/s -> Telemere.
 

check-err-intake

clj

(check-err-intake)
Returns {:keys [sending->telemere? telemere-receiving?]}.
 

check-out-intake

clj

(check-out-intake)
Returns {:keys [sending->telemere? telemere-receiving?]}.
 

streams->reset!

clj

(streams->reset!)
Experimental, subject to change.
diff --git a/taoensso.telemere.timbre.cljs.html b/taoensso.telemere.timbre.cljs.html
index b32bb82..ce0fdde 100644
--- a/taoensso.telemere.timbre.cljs.html
+++ b/taoensso.telemere.timbre.cljs.html
@@ -1,6 +1,6 @@
 
-taoensso.telemere.timbre documentation

taoensso.telemere.timbre

Main Timbre macros, reimplemented on top of Telemere.
+taoensso.telemere.timbre documentation

taoensso.telemere.timbre

Main Timbre macros, reimplemented on top of Telemere.
 Intended to help ease migration from Timbre to Telemere.

set-min-level!

clj

cljs

(set-min-level! min-level)
Prefer `telemere/set-min-level!`.
 

shutdown-appenders!

clj

cljs

(shutdown-appenders!)
Prefer `telemere/shut-down-handlers!`.
 
\ No newline at end of file diff --git a/taoensso.telemere.timbre.html b/taoensso.telemere.timbre.html index 2e07e3e..271d6cd 100644 --- a/taoensso.telemere.timbre.html +++ b/taoensso.telemere.timbre.html @@ -1,6 +1,6 @@ -taoensso.telemere.timbre documentation

taoensso.telemere.timbre

Main Timbre macros, reimplemented on top of Telemere.
+taoensso.telemere.timbre documentation

taoensso.telemere.timbre

Main Timbre macros, reimplemented on top of Telemere.
 Intended to help ease migration from Timbre to Telemere.

debug

macro

clj

(debug & args)
Prefer `telemere/log!`, etc.
 

debugf

macro

clj

(debugf & args)
Prefer `telemere/log!`, etc.
 

error

macro

clj

(error & args)
Prefer `telemere/log!`, etc.
diff --git a/taoensso.telemere.tools-logging.html b/taoensso.telemere.tools-logging.html
index 3f4886c..a0794da 100644
--- a/taoensso.telemere.tools-logging.html
+++ b/taoensso.telemere.tools-logging.html
@@ -1,6 +1,6 @@
 
-taoensso.telemere.tools-logging documentation

taoensso.telemere.tools-logging

Intake support for `clojure.tools.logging` -> Telemere.
+taoensso.telemere.tools-logging documentation

taoensso.telemere.tools-logging

Intake support for `clojure.tools.logging` -> Telemere.
 Telemere will attempt to load this ns automatically when possible.

check-intake

clj

(check-intake)
Returns {:keys [present? sending->telemere? telemere-receiving?]}.
 

tools-logging->telemere!

clj

(tools-logging->telemere!)
Configures `clojure.tools.logging` to use Telemere as its logging implementation.
 
diff --git a/taoensso.telemere.utils.cljs.html b/taoensso.telemere.utils.cljs.html
index bfdfae1..0316bc2 100644
--- a/taoensso.telemere.utils.cljs.html
+++ b/taoensso.telemere.utils.cljs.html
@@ -1,6 +1,6 @@
 
-taoensso.telemere.utils documentation

taoensso.telemere.utils

Misc utils useful for Telemere handlers, middleware, etc.
+taoensso.telemere.utils documentation

taoensso.telemere.utils

Misc utils useful for Telemere handlers, middleware, etc.
 

error-in-signal->maps

clj

cljs

(error-in-signal->maps signal)
Experimental, subject to change.
 Returns given signal with possible `:error` replaced by
 [{:keys [type msg data]} ...] cause chain.
@@ -27,22 +27,12 @@ Options:
 Returns a (fn format [nanosecs]) that:
   - Takes a long nanoseconds (e.g. runtime).
   - Returns a formatted human-readable string like:
-    "1.00m", "4.20s", "340ms", "822μs", etc.

format-signal->edn-fn

clj

cljs

(format-signal->edn-fn)(format-signal->edn-fn {:keys [pr-edn-fn prep-fn], :or {pr-edn-fn pr-edn, prep-fn (comp error-in-signal->maps minify-signal)}})
Experimental, subject to change.
-Returns a (fn format->edn [signal]) that:
-  - Takes a Telemere signal.
-  - Returns edn string of the (minified) signal.

format-signal->json-fn

clj

cljs

(format-signal->json-fn)(format-signal->json-fn {:keys [pr-json-fn prep-fn], :or {pr-json-fn pr-json, prep-fn (comp error-in-signal->maps minify-signal)}})
Experimental, subject to change.
-Returns a (fn format->json [signal]) that:
-  - Takes a Telemere signal.
-  - Returns JSON string of the (minified) signal.
-
-(Clj only): An appropriate `:pr-json-fn` MUST be provided.

format-signal->prelude-fn

clj

cljs

(format-signal->prelude-fn)(format-signal->prelude-fn {:keys [format-inst-fn], :or {format-inst-fn (format-inst-fn)}})
Experimental, subject to change.
+    "1.00m", "4.20s", "340ms", "822μs", etc.

format-signal-fn

clj

cljs

(format-signal-fn)(format-signal-fn {:keys [incl-newline? preamble-fn content-fn], :or {incl-newline? true, preamble-fn (signal-preamble-fn), content-fn (signal-content-fn)}})
Experimental, subject to change.
 Returns a (fn format [signal]) that:
   - Takes a Telemere signal.
-  - Returns a formatted prelude string like:
-    "2024-03-26T11:14:51.806Z INFO EVENT Hostname taoensso.telemere(2,21) ::ev-id - msg"

format-signal->str-fn

clj

cljs

(format-signal->str-fn)(format-signal->str-fn {:keys [format-signal->prelude-fn format-nsecs-fn format-error-fn], :or {format-signal->prelude-fn (format-signal->prelude-fn), format-nsecs-fn (format-nsecs-fn), format-error-fn (format-error-fn)}})
Experimental, subject to change.
-Returns a (fn format->str [signal]) that:
-  - Takes a Telemere signal.
-  - Returns a formatted string intended for text consoles, etc.

js-console-logger

cljs

(js-console-logger level)
Returns JavaScript console logger to match given signal level:
+  - Returns human-readable formatted string.
+
+See also `pr-signal-fn` for machine-readable output.

js-console-logger

cljs

(js-console-logger level)
Returns JavaScript console logger to match given signal level:
   `:trace` -> `js/console.trace`,
   `:error` -> `js/console.error`, etc.
 
@@ -55,5 +45,34 @@ Returns minimal signal map, removing:
 Useful when serializing signals to edn/JSON/etc.

newline

clj

cljs

added in Encore v3.68.0 (2023-09-25)

Single system newline
 

pr-edn

clj

cljs

(pr-edn x)
Prints given arg to an edn string readable with `read-edn`.
 

pr-json

cljs

added in Encore v3.98.0 (2024-04-08)

(pr-json x)
Returns given Cljs argument as JSON string.
-

remove-kvs

clj

cljs

(remove-kvs signal)
Returns the given signal without user-level kvs.
-
\ No newline at end of file +

pr-signal-fn

clj

cljs

(pr-signal-fn pr-fn)(pr-signal-fn pr-fn {:keys [incl-thread? incl-kvs? incl-newline? prep-fn], :or {incl-newline? true, prep-fn (comp error-in-signal->maps minify-signal)}})
Experimental, subject to change.
+Returns a (fn pr-signal [signal]) that:
+  - Takes a Telemere signal.
+  - Returns machine-readable serialized string of the (minified) signal.
+
+Options include:
+  `pr-fn` ∈ #{<unary-fn> :edn :json (Cljs only)}
+  See arglists for more.
+
+Examples:
+  (pr-signal-fn :edn  {<opts>})
+  (pr-signal-fn :json {<opts>}) ; Cljs only
+
+  ;; To output JSON for Clj, you must provide an appropriate `pr-fn`.
+  ;; `jsonista` is a good option, Ref. <https://github.com/metosin/jsonista>:
+    (require '[jsonista.core :as jsonista])
+    (pr-signal-fn jsonista/write-value-as-string {<opts>})
+
+See also `format-signal-fn` for human-readable output.

remove-kvs

clj

cljs

(remove-kvs signal)
Returns the given signal without user-level kvs.
+

signal-content-fn

clj

cljs

(signal-content-fn)(signal-content-fn {:keys [incl-thread? incl-kvs? raw-error? format-nsecs-fn format-error-fn], :or {format-nsecs-fn (format-nsecs-fn), format-error-fn (format-error-fn)}})
Experimental, subject to change.
+Returns a (fn content [signal]) that:
+  - Takes a Telemere signal.
+  - Returns a signal content ?string (incl. data, ctx, etc.)
+
+See arglists for options.

signal-preamble-fn

clj

cljs

(signal-preamble-fn)(signal-preamble-fn {:keys [format-inst-fn], :or {format-inst-fn (format-inst-fn)}})
Experimental, subject to change.
+Returns a (fn preamble [signal]) that:
+  - Takes a Telemere signal.
+  - Returns a signal preamble ?string like:
+    "2024-03-26T11:14:51.806Z INFO EVENT Hostname taoensso.telemere(2,21) ::ev-id - msg"
+
+See arglists for options.
\ No newline at end of file diff --git a/taoensso.telemere.utils.html b/taoensso.telemere.utils.html index 102078c..a90d704 100644 --- a/taoensso.telemere.utils.html +++ b/taoensso.telemere.utils.html @@ -1,6 +1,6 @@ -taoensso.telemere.utils documentation

taoensso.telemere.utils

Misc utils useful for Telemere handlers, middleware, etc.
+taoensso.telemere.utils documentation

taoensso.telemere.utils

Misc utils useful for Telemere handlers, middleware, etc.
 

error-in-signal->maps

clj

cljs

(error-in-signal->maps signal)
Experimental, subject to change.
 Returns given signal with possible `:error` replaced by
 [{:keys [type msg data]} ...] cause chain.
@@ -39,22 +39,12 @@ Options:
 Returns a (fn format [nanosecs]) that:
   - Takes a long nanoseconds (e.g. runtime).
   - Returns a formatted human-readable string like:
-    "1.00m", "4.20s", "340ms", "822μs", etc.

format-signal->edn-fn

clj

cljs

(format-signal->edn-fn)(format-signal->edn-fn {:keys [pr-edn-fn prep-fn], :or {pr-edn-fn pr-edn, prep-fn (comp error-in-signal->maps minify-signal)}})
Experimental, subject to change.
-Returns a (fn format->edn [signal]) that:
-  - Takes a Telemere signal.
-  - Returns edn string of the (minified) signal.

format-signal->json-fn

clj

cljs

(format-signal->json-fn)(format-signal->json-fn {:keys [pr-json-fn prep-fn], :or {prep-fn (comp error-in-signal->maps minify-signal)}})
Experimental, subject to change.
-Returns a (fn format->json [signal]) that:
-  - Takes a Telemere signal.
-  - Returns JSON string of the (minified) signal.
-
-(Clj only): An appropriate `:pr-json-fn` MUST be provided.

format-signal->prelude-fn

clj

cljs

(format-signal->prelude-fn)(format-signal->prelude-fn {:keys [format-inst-fn], :or {format-inst-fn (format-inst-fn)}})
Experimental, subject to change.
+    "1.00m", "4.20s", "340ms", "822μs", etc.

format-signal-fn

clj

cljs

(format-signal-fn)(format-signal-fn {:keys [incl-newline? preamble-fn content-fn], :or {incl-newline? true, preamble-fn (signal-preamble-fn), content-fn (signal-content-fn)}})
Experimental, subject to change.
 Returns a (fn format [signal]) that:
   - Takes a Telemere signal.
-  - Returns a formatted prelude string like:
-    "2024-03-26T11:14:51.806Z INFO EVENT Hostname taoensso.telemere(2,21) ::ev-id - msg"

format-signal->str-fn

clj

cljs

(format-signal->str-fn)(format-signal->str-fn {:keys [format-signal->prelude-fn format-nsecs-fn format-error-fn], :or {format-signal->prelude-fn (format-signal->prelude-fn), format-nsecs-fn (format-nsecs-fn), format-error-fn (format-error-fn)}})
Experimental, subject to change.
-Returns a (fn format->str [signal]) that:
-  - Takes a Telemere signal.
-  - Returns a formatted string intended for text consoles, etc.

host-ip

clj

(host-ip timeout-msecs timeout-val)(host-ip)
Returns cached local host IP address string, or `timeout-val` (default "UnknownHost").
+  - Returns human-readable formatted string.
+
+See also `pr-signal-fn` for machine-readable output.

host-ip

clj

(host-ip timeout-msecs timeout-val)(host-ip)
Returns cached local host IP address string, or `timeout-val` (default "UnknownHost").
 

hostname

clj

(hostname timeout-msecs timeout-val)(hostname)
Returns cached local hostname string, or `timeout-val` (default "UnknownHost").
 

minify-signal

clj

cljs

(minify-signal signal)
Experimental, subject to change.
 Returns minimal signal map, removing:
@@ -63,7 +53,57 @@ Returns minimal signal map, removing:
 
 Useful when serializing signals to edn/JSON/etc.

newline

clj

cljs

added in Encore v3.68.0 (2023-09-25)

Single system newline
 

pr-edn

clj

cljs

(pr-edn x)
Prints given arg to an edn string readable with `read-edn`.
-

remove-kvs

clj

cljs

(remove-kvs signal)
Returns the given signal without user-level kvs.
-

thread-id

clj

(thread-id)
Returns long id of current thread.
+

pr-signal-fn

clj

cljs

(pr-signal-fn pr-fn)(pr-signal-fn pr-fn {:keys [incl-thread? incl-kvs? incl-newline? prep-fn], :or {incl-newline? true, prep-fn (comp error-in-signal->maps minify-signal)}})
Experimental, subject to change.
+Returns a (fn pr-signal [signal]) that:
+  - Takes a Telemere signal.
+  - Returns machine-readable serialized string of the (minified) signal.
+
+Options include:
+  `pr-fn` ∈ #{<unary-fn> :edn :json (Cljs only)}
+  See arglists for more.
+
+Examples:
+  (pr-signal-fn :edn  {<opts>})
+  (pr-signal-fn :json {<opts>}) ; Cljs only
+
+  ;; To output JSON for Clj, you must provide an appropriate `pr-fn`.
+  ;; `jsonista` is a good option, Ref. <https://github.com/metosin/jsonista>:
+    (require '[jsonista.core :as jsonista])
+    (pr-signal-fn jsonista/write-value-as-string {<opts>})
+
+See also `format-signal-fn` for human-readable output.

remove-kvs

clj

cljs

(remove-kvs signal)
Returns the given signal without user-level kvs.
+

signal-content-fn

clj

cljs

(signal-content-fn)(signal-content-fn {:keys [incl-thread? incl-kvs? raw-error? format-nsecs-fn format-error-fn], :or {format-nsecs-fn (format-nsecs-fn), format-error-fn (format-error-fn)}})
Experimental, subject to change.
+Returns a (fn content [signal]) that:
+  - Takes a Telemere signal.
+  - Returns a signal content ?string (incl. data, ctx, etc.)
+
+See arglists for options.

signal-preamble-fn

clj

cljs

(signal-preamble-fn)(signal-preamble-fn {:keys [format-inst-fn], :or {format-inst-fn (format-inst-fn)}})
Experimental, subject to change.
+Returns a (fn preamble [signal]) that:
+  - Takes a Telemere signal.
+  - Returns a signal preamble ?string like:
+    "2024-03-26T11:14:51.806Z INFO EVENT Hostname taoensso.telemere(2,21) ::ev-id - msg"
+
+See arglists for options.

tcp-socket-writer

clj

(tcp-socket-writer host port {:keys [ssl? connect-timeout-msecs socket-fn ssl-socket-fn], :as opts, :or {connect-timeout-msecs 3000, socket-fn default-socket-fn, ssl-socket-fn default-ssl-socket-fn}})
Experimental, subject to change. Feedback welcome!
+
+Connects to specified TCP socket and returns a stateful fn of 2 arities:
+  [content] => Writes given content to socket, or no-ops if closed.
+  []        => Closes the writer.
+
+Useful for basic handlers that write to a TCP socket, etc.
+
+Options:
+  `:ssl?`                  - Use SSL/TLS?
+  `:connect-timeout-msecs` - Connection timeout (default 3000 msecs)
+  `:socket-fn`             - (fn [host port timeout]) => `java.net.Socket`
+  `:ssl-socket-fn`         - (fn [socket host port])  => `java.net.Socket`
+
+Notes:
+  - Writer should be manually closed after use (with zero-arity call).
+  - Flushes after every write.
+  - Will retry failed writes once, then drop.
+  - Thread safe, locks on single socket stream.
+  - Advanced users may want a custom implementation using a connection
+    pool and/or more sophisticated retry semantics, etc.

thread-id

clj

(thread-id)
Returns long id of current thread.
+

thread-info

clj

(thread-info)
Returns {:keys [group name id]} for current thread.
 

thread-name

clj

(thread-name)
Returns string name of current thread.
 
\ No newline at end of file