This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-25
Channels
- # asami (5)
- # babashka (38)
- # beginners (116)
- # calva (65)
- # chlorine-clover (4)
- # cider (8)
- # cljfx (6)
- # cljsrn (7)
- # clojure (18)
- # clojure-australia (1)
- # clojure-europe (49)
- # clojure-spec (6)
- # clojure-uk (4)
- # clojurescript (3)
- # clojureverse-ops (13)
- # core-async (2)
- # cryogen (1)
- # cursive (9)
- # datahike (32)
- # fulcro (3)
- # gratitude (17)
- # malli (4)
- # music (3)
- # nrepl (8)
- # off-topic (14)
- # releases (2)
- # rewrite-clj (3)
- # shadow-cljs (4)
- # vrac (1)
- # xtdb (4)
Heya, I'm connecting to an embedded remote REPL server (as in: nrepl.server/start-server
with cider.nrepl/cider-nrepl-handler
) via M-x cider-connect
which works fine except for one problem: The main process is a server which writes (a lot of) log output to stderr. This all gets redirected into my REPL buffer, often grinding my Emacs instance to a halt. Is anyone aware of a way to deal with this? I could live with only having stdout redirected, for example.
The usual thing I do is disabling stdout/stderr logging in my app by tweaking my app's Logback (or Timbre, or what have you) config
I make it log to log/dev.log
instead which I can tail -f
if necessary
(bonus tip, less +F
is awesome https://www.brianstorti.com/stop-using-tail/ )
Hey @U45T93RA6, thanks for your reply (and the nice bonus tip :D). However, logging to files is something I would prefer to avoid since that means having to take care of log rotation, compaction and purging, as well. I'd rather leave that concern to journald 😄
The trick is that you only tweak logging in your dev env, where rotation is not a concern
Sometimes (but not necessarily) I (File/delete "log/dev.log")
on app startup, mostly so that old logs don't confuse me when debugging
Ah yeah, I am actually talking about REPLing into a production server for purposes of doing some runtime state inspection.
Got it So I have a snippet that should help:
(let [silently--old System/out
silently--pw (java.io.PrintWriter. "/dev/null")
silently--ps (java.io.PrintStream. (proxy [java.io.OutputStream] []
(write
([a])
([a b c])
([a b c d e]))))]
(binding [*out* silently--pw
*err* silently--pw]
(try
(System/setOut silently--ps)
(System/setErr silently--ps)
;; do your thing here...
(finally
(System/setOut silently--old)
(System/setErr silently--old)))))
the snippet is oriented for use in e.g. test suites but you can trivially adapt it for repl usage (e.g. binding
-> set!
)
good ol' dev/null