Utilities for injecting out intercepting writers for System.out and err.
Utilities for injecting out intercepting writers for System.out and err.
(remove-callback stream key)Remove a previously registered callback for a stream.
stream - either :out or :err.key - a unique identifier that was used when adding the callback.Remove a previously registered callback for a stream. - `stream` - either `:out` or `:err`. - `key` - a unique identifier that was used when adding the callback.
(set-callback stream key callback)Register or update a callback that is invoked when output is written to stream.
stream - should be :out or :err to specify which stream to monitor.key - a unique identifier for this callback (used for removal).callback - a function that takes a string argument - the line or lines
sent to the output stream. Multiple callbacks can be registered for the same
stream using different keys.Register or update a callback that is invoked when output is written to stream. - `stream` - should be `:out` or `:err` to specify which stream to monitor. - `key` - a unique identifier for this callback (used for removal). - `callback` - a function that takes a string argument - the line or lines sent to the output stream. Multiple callbacks can be registered for the same stream using different keys.
(wrap-standard-streams)Wraps and substitutes System/out and System/err to enable output
interception via callbacks. After calling this function:
The wrapping is idempotent - calling this function multiple times has no additional effect after the first call. This should typically called once during nREPL server initialization to enable output capture for all evaluation contexts.
Note: This makes global changes to the JVM's standard streams that affect all threads and code running in the same JVM process.
Wraps and substitutes `System/out` and `System/err` to enable output interception via callbacks. After calling this function: 1. All output to System/out and System/err will be teed - it goes to both the original destinations and triggers any registered callbacks. 2. The root bindings of *out* and *err* are updated to use the wrapped streams. 3. clojure.test/*test-out* is also rebound if clojure.test is loaded. The wrapping is idempotent - calling this function multiple times has no additional effect after the first call. This should typically called once during nREPL server initialization to enable output capture for all evaluation contexts. Note: This makes global changes to the JVM's standard streams that affect all threads and code running in the same JVM process.
Atom that contains true if standard streams have been wrapped
by nREPL to enable output forwarding.
Atom that contains `true` if standard streams have been wrapped by nREPL to enable output forwarding.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |