Portal Debugger

Back to SIG Tooling & Set Up Tutorials

Background Information

Docs for tap>
Docs for datafy
Docs for nav

More detailed datafy/nav writeup

Other Debugger Options

REBL Data Browser

Setup And Configuration

Project Repository
All Portal Documentation
Editor integration

Installation: Leiningen

Insert the following into your base `~/.lein/profiles.clj` file to include Portal in your runtime.

{:user {:dependencies [[djblue/portal "RELEASE"]]}}

Insert the following into your base `~/.lein/profiles.clj` file to have Portal automatically start up with your repl

{:user {:dependencies [[djblue/portal "0.19.2"]]
        :repl-options {:welcome (do
		          (ns dev)
              (def portal ((requiring-resolve 'portal.api/open)))
              (add-tap (requiring-resolve 'portal.api/submit)))}}}

Installation: Deps

Insert the following into your base `deps.edn`

djblue/portal {:mvn/version "RELEASE"}

Usage

A lot of this will come down to your personal preference, but I like to work similarly to this:

Say for example that we have a function that is misbehavin' and we don't understand how or why

(defn very-good-function
  “This is the best code I’ve ever written!”
  [param1 param2]
  (let [bound1 (foo param1 param2)
         bound2 (this-is-a-kanye-west-reference param2)]
    (tap> {:param1 param1
              :param2 param2
              :bound1 bound1})
    (other-code bound1 bound2)))

That's pretty nice function, eh? Let's debug it.

First, notice the usage of `tap>` above. It's being passed a map of key value pairs. This isn't necessary, but I find it to be extremely useful at taking as much guesswork out of the debugging process as possible.

Next, select the data that you'd like to access in the Portal UI.

Assuming that you've `def`ed the Portal object to the `dev` namespace, you can dereference it with @dev/portal.

I quite like using rich comment blocks here. They allow me to poke at very specific bits of code with real data of my choosing.

(comment
  (let [{:keys [param1 param2 bound1] @dev/portal}]
    (this-is-a-kanye-west-reference param2)))

In this example, we may notice that the call to `this-is-a-kanye-west-reference` produces results that aren't what we expect.

We can then go further down that rabbit hole and apply the same process.

Talks And Tutorials

Slideshow From Lightning Talk
Older Clojure Debugger Guide I Wrote
Thinking With Portal
Portal Apropos Demo (first public demo)