【问题标题】:Timbre macro 'p' can't be resolved but other Timbre macros can be无法解析音色宏“p”,但可以解析其他音色宏
【发布时间】:2014-03-07 02:25:45
【问题描述】:

每当我尝试在函数中包含 Timbre p 语句时,都会出现错误:

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

输出(苹果酒/nrepl)

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

但是像profilespy 这样的其他音色函数/宏可以正常工作。

【问题讨论】:

  • 可能值得注意的是:1. 分析不适用于 cljs 2. 分析已移至新项目 tufte 3. tufte 版本 2.0.1 doesn't work in cljs

标签: clojure profiling timbre


【解决方案1】:

p profiling 宏is not exposed with refer-timbre,文档好像已经过时了。

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

作为you see herep 只是pspy 的别名

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

所以你可以改用pspy

【讨论】:

  • 案件结束!谢谢
【解决方案2】:

如果您只是对开发 time 函数所花费的时间感兴趣,就足够了。

(time (some-work))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-25
    • 2019-09-05
    • 1970-01-01
    • 1970-01-01
    • 2016-01-21
    • 1970-01-01
    • 2013-09-16
    • 1970-01-01
    相关资源
    最近更新 更多