mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 16:31:11 +00:00
Fix capture-console on node
This commit is contained in:
parent
73b1efd5b3
commit
5024223280
1 changed files with 3 additions and 7 deletions
|
|
@ -2,18 +2,14 @@
|
|||
|
||||
(defn capture-console [f]
|
||||
(let [messages (atom [])
|
||||
original-console js/console
|
||||
original-console-warn js/console.warn
|
||||
log (fn [t & message]
|
||||
(swap! messages conj {:type t
|
||||
:message message}))
|
||||
value (try
|
||||
(set! js/console #js {:log (partial log :log)
|
||||
:warn (partial log :warn)
|
||||
:info (partial log :info)
|
||||
:error (partial log :error)
|
||||
:debug (partial log :debug)})
|
||||
(set! js/console.warn (partial log :warn))
|
||||
(f)
|
||||
(finally
|
||||
(set! js/console original-console)))]
|
||||
(set! js/console.warn original-console-warn)))]
|
||||
{:value value
|
||||
:messages @messages}))
|
||||
|
|
|
|||
Loading…
Reference in a new issue