Search code examples
clojurecompojure

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).


Solution

  • 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