File tree Expand file tree Collapse file tree 5 files changed +57
-6
lines changed Expand file tree Collapse file tree 5 files changed +57
-6
lines changed Original file line number Diff line number Diff line change 22
33## master (unreleased)
44
5+ * The _ class info cache_ is now initialized silently by default. This results in less confusing output.
6+ * You can now ` @orchard.java/cache-initializer ` for deterministically waiting for this cache workload to complete.
7+ * You can control its verbosity by setting ` "-Dorchard.initialize-cache.silent=false" ` (or ` [...]=true ` ).
8+
59## 0.6.5 (2021-02-13)
610
711### Bugs Fixed
Original file line number Diff line number Diff line change @@ -86,6 +86,14 @@ Just add `orchard` as a dependency and start hacking.
8686Consult the [ API documentation] ( https://cljdoc.org/d/cider/orchard/CURRENT ) to get a better idea about the
8787functionality that's provided.
8888
89+ ## Configuration options
90+
91+ So far, Orchard follows these options, which can be specified as Java system properties
92+ (which means that end users can choose to set them globally without fiddling with tooling internals):
93+
94+ * ` "-Dorchard.initialize-cache.silent=true" ` (default: ` true ` )
95+ * if false, the _ class info cache_ initialization may print warnings (possibly spurious ones).
96+
8997## History
9098
9199Originally [ SLIME] [ ] was the most
Original file line number Diff line number Diff line change 3838 :dependencies [[org.clojure/clojure " 1.11.0-master-SNAPSHOT" ]
3939 [org.clojure/clojure " 1.11.0-master-SNAPSHOT" :classifier " sources" ]]}
4040
41- :test {:resource-paths [" test-resources" ]}
41+ :test {:resource-paths [" test-resources" ]
42+ ; ; Initialize the cache verbosely, as usual, so that possible issues can be more easily diagnosed:
43+ :jvm-opts [" -Dorchard.initialize-cache.silent=false" ]}
4244
4345 ; ; Development tools
4446 :dev {:dependencies [[pjstadig/humane-test-output " 0.10.0" ]]
Original file line number Diff line number Diff line change 88 [clojure.string :as str]
99 [orchard.java.classpath :as cp]
1010 [orchard.misc :as misc]
11- [orchard.java.resource :as resource])
11+ [orchard.java.resource :as resource]
12+ [orchard.util.io :as util.io])
1213 (:import
1314 (clojure.lang IPersistentMap)
1415 (clojure.reflect Constructor Field JavaReflector Method)
421422 (javadoc-base-urls 11 ))))))
422423 path))
423424
424- ; ;; ## Initialization
425- ; ;
426- ; ; On startup, cache info for the most commonly referenced classes.
427- (future
425+ (defn- initialize-cache!* []
428426 (doseq [class (->> (ns-imports 'clojure.core)
429427 (map #(-> % ^Class val .getName symbol)))]
430428 (class-info class)))
429+
430+ (def initialize-cache-silently?
431+ " Should `#'cache-initializer` refrain from printing to `System/out`?"
432+ (= " true" (System/getProperty " orchard.initialize-cache.silent" " true" )))
433+
434+ (def ^:private initialize-cache!
435+ (cond-> initialize-cache!*
436+ initialize-cache-silently? util.io/wrap-silently))
437+
438+ (def cache-initializer
439+ " On startup, cache info for the most commonly referenced classes.
440+
441+ This is a def for allowing others to wait for this workload to complete (can be useful sometimes)."
442+ (future
443+ (initialize-cache! )))
Original file line number Diff line number Diff line change 1+ (ns orchard.util.io )
2+
3+ (defn wrap-silently
4+ " Middleware that executes `(f)` without printing to `System/out` or `System/err`.
5+
6+ (Note that `System/out` is different from `*out*`)"
7+ [f]
8+ (fn []
9+ (let [old-out System/out
10+ old-err System/err
11+ ps (java.io.PrintStream. (proxy [java.io.OutputStream] []
12+ (write
13+ ([a])
14+ ([a b c])
15+ ([a b c d e]))))]
16+ (try
17+ (System/setOut ps)
18+ (System/setErr ps)
19+ (f )
20+ (finally
21+ (when (= ps System/out) ; ; `System/out` may have changed in the meantime (in face of concurrency)
22+ (System/setOut old-out))
23+ (when (= ps System/err) ; ; `System/err` may have changed in the meantime (in face of concurrency)
24+ (System/setErr old-err)))))))
You can’t perform that action at this time.
0 commit comments