2

Whenever I try to include a Timbre p statement in a function I get an error:

project.clj

 (defproject sketch "0.1.0-SNAPSHOT"
      :description "FIXME: write description"
      :url "http://example.com/FIXME"
      :license {:name "Eclipse Public License"
                :url "http://www.eclipse.org/legal/epl-v10.html"}
      :dependencies [[org.clojure/clojure "1.5.1"]
                     [com.taoensso/timbre "3.1.1"]])

core.clj

(ns user (:require [taoensso.timbre :as timbre])) 
(timbre/refer-timbre)

(defn tst [a]
  (p :tf (+ a a)))

Output (cider/nrepl)

 Unable to resolve symbol: p in this context, compiling:(NO_SOURCE_PATH:2:3)

But other Timbre functions/macros like profile and spy work fine.

Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
Bwalsh1001
  • 85
  • 6
  • It might be worth noting that: 1. profiling doesn't work for cljs 2. profiling moved to a new project, [tufte](https://github.com/ptaoussanis/tufte) 3. tufte version 2.0.1 [doesn't work in cljs](https://github.com/ptaoussanis/tufte/issues/33) – Jp_ Feb 19 '19 at 12:19

2 Answers2

2

The p profiling macro is not exposed with refer-timbre, the documentation seems to be outdated.

(require
   '[taoensso.timbre.profiling :as profiling :refer (pspy pspy* profile defnp)])

As you see here, p is just an alias for pspy

 (defmacro p [id & body] `(pspy ~id ~@body)) ; Alias

So you can use pspy instead.

guilespi
  • 4,672
  • 1
  • 15
  • 24
0

If you are just interested in the time it took while you are developing the time function can be enough.

(time (some-work))
Jp_
  • 5,973
  • 4
  • 25
  • 36