Skip to content

Commit

Permalink
fixed private functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Domagala committed Nov 18, 2021
1 parent cc41f2a commit 1732c4d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pom.xml
.cpcache/
.shadow-cljs/
.cljs_node_repl/
out/
target/
node_modules/
resources/public/js/
.clj-kondo/.cache/
Expand Down
28 changes: 28 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(ns build
(:require [clojure.tools.build.api :as b]
[org.corfield.build :as bb]))

(def lib 'org.clojars.cyrik/omni-trace)
;; if you want a version of MAJOR.MINOR.COMMITS:
(def version (format "0.1.%s" (b/git-count-revs nil)))

(defn clean "clean" [opts]
(-> opts
(assoc :lib lib :version version)
(bb/clean)))

(defn install "Install the JAR locally." [opts]
(-> opts
(assoc :lib lib :version version)
(bb/install)))

(defn jar "Build jar." [opts]
(-> opts
(assoc :lib lib :version version)
(bb/jar)))

(defn deploy "Deploy the JAR to Clojars." [opts]
(-> opts
(assoc :lib lib :version version)
(bb/jar)
(bb/deploy)))
8 changes: 5 additions & 3 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
net.cgrand/macrovich {:mvn/version "0.2.1"}
org.clojure/clojurescript {:mvn/version "1.10.879"}}
:aliases {:check {:extra-deps
:aliases {:build {:deps {io.github.seancorfield/build-clj
{:git/tag "v0.5.4" :git/sha "bc9c0cc"}}
:ns-default build}
:check {:extra-deps
{athos/clj-check
{:git/url "https://github.com/athos/clj-check.git"
:sha "0ca84df1357d71429243b99908303f45a934654c"}}
:main-opts ["-M" "clj-check.check"]}
:dev {:extra-paths ["dev"]
:extra-deps {djblue/portal {:mvn/version "0.16.3"}}}
:shadow-cljs
{:extra-deps {
thheller/shadow-cljs {:mvn/version "2.15.5"}}}
{:extra-deps {thheller/shadow-cljs {:mvn/version "2.15.5"}}}
;:main-opts ["-m" "shadow.cljs.devtools.cli" "watch" "app"]}
:cljs {:extra-deps
{org.clojure/clojurescript {:mvn/version "1.10.879"}}}}}
Expand Down
35 changes: 35 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<groupId>org.clojars.cyrik</groupId>
<artifactId>omni-trace</artifactId>
<version>LATEST</version>
<name>omni-trace</name>
<description>Omnipotent/omniscient tracing core for debugging clojure(script)</description>
<url>https://github.com/Cyrik/omni-trace</url>
<repositories>
<repository>
<id>clojars</id>
<url>https://repo.clojars.org/</url>
</repository>
</repositories>
<scm>
<url>https://github.com/Cyrik/omni-trace</url>
<connection>scm:git:git://github.com/Cyrik/omni-trace.git</connection>
<developerConnection>scm:git:ssh://[email protected]/Cyrik/omni-trace.git</developerConnection>
<tag>HEAD</tag>
</scm>
<developers>
<developer>
<name>Lukas Domagala</name>
</developer>
</developers>
<licenses>
<license>
<name>Eclipse Public License</name>
<url>http://www.eclipse.org/legal/epl-v10.html</url>
</license>
</licenses>

</project>
10 changes: 5 additions & 5 deletions src/omni_trace/omni_trace.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
(def ^:dynamic *trace-log-parent* nil)
(defonce workspace (atom {}))

(defn- now []
(defn now []
#?(:clj (System/currentTimeMillis)
:cljs (.now js/Date)))

(defn- trace-fn-call [name f args opts]
(defn trace-fn-call [name f args opts]
(let [parent (or *trace-log-parent*
{:workspace (::workspace opts) :parent :root})
call-id (keyword (gensym))
Expand All @@ -26,15 +26,15 @@
#(assoc % call-id {:id call-id :name name :args args :start before-time :end (now) :parent (:parent parent) :return res}))
res))

(defn- instrumented [sym v opts]
(defn instrumented [sym v opts]
(let [to-wrap @v]
(when (fn? to-wrap)
(let [instrumented (fn [& args]
(trace-fn-call sym to-wrap args opts))]
(swap! instrumented-vars assoc v {:orig to-wrap :instrumented instrumented})
instrumented))))

(defn- uninstrumented [sym v opts]
(defn uninstrumented [sym v opts]
(when-let [wrapped (@instrumented-vars v)]
(swap! instrumented-vars dissoc v)
(:orig wrapped)))
Expand All @@ -47,7 +47,7 @@
[]))

(macros/deftime
(defn- ->sym [v]
(defn ->sym [v]
(let [meta (meta v)]
(symbol (name (ns-name (:ns meta))) (name (:name meta)))))

Expand Down

0 comments on commit 1732c4d

Please sign in to comment.