简体   繁体   中英

Output compojure server print statements into figwheel terminal?

Where does pprint / println output go in compojure?/Can I get it to show up in the terminal window that the figwheel repl is running in? (Sorry if this sounds dumb, google bested my efforts).

Actually Figwheel has a related feature to cause such symptoms. All print/prn statements in your ring handlers will be "swallowed" by the Figwheel process and will either go to a log file or to the console.

Here is a snippet from project.clj:

 :figwheel
  {:http-server-root "public"
   :server-port 3449
   :nrepl-port 7002
   :css-dirs ["resources/public/css"]
   :ring-handler myapp.handler/app
   :server-logfile false
   }

The key :server-logfile is controlling this behavior. If it's false, then out is your regular repl console, if it's a filename, then anything printed will go to that file (if it's not present, then the default is using file "figwheel_server.log".

Figwheel issue: https://github.com/bhauman/lein-figwheel/issues/436 Figwheel commit: https://github.com/bhauman/lein-figwheel/commit/330d8d7fda8be145615910cf639bd9a3242339ba

It seems to show up there without any special setup... I get this at the console:

Prompt will show when Figwheel connects to your application
"I got a request"

Triggering the handler:

curl localhost:3449/foo

src/with_server/server.clj

(ns with-server.server)

(defn handler [req]
  (prn "I got a request")
  {})

In project.clj under :figwheel {}

:ring-handler with-server.server/handler

If you are having trouble, maybe you need ring-reload middleware so that the changes you are making get reloaded?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM