(defn log-capture!
"Captures System.out and System.err, redirecting all writes of those streams
to :info and :error logging, respectively. The specified log-ns value will
be used to namespace all redirected logging. NOTE: this will not redirect
output of *out* or *err*; for that, use with-logs."
[log-ns]
(dosync
(let [new-out (log-stream :info log-ns)
new-err (log-stream :error log-ns)]
; don't overwrite the original values
(if (nil? @*old-std-streams*)
(ref-set *old-std-streams* {:out System/out :err System/err}))
(System/setOut new-out)
(System/setErr new-err))))
Used in 0 other vars
Comments top
No comments for log-capture!. Log in to add a comment.