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 2
2
3
3
## master (unreleased)
4
4
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
+
5
9
## 0.6.5 (2021-02-13)
6
10
7
11
### 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.
86
86
Consult the [ API documentation] ( https://cljdoc.org/d/cider/orchard/CURRENT ) to get a better idea about the
87
87
functionality that's provided.
88
88
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
+
89
97
## History
90
98
91
99
Originally [ SLIME] [ ] was the most
Original file line number Diff line number Diff line change 38
38
:dependencies [[org.clojure/clojure " 1.11.0-master-SNAPSHOT" ]
39
39
[org.clojure/clojure " 1.11.0-master-SNAPSHOT" :classifier " sources" ]]}
40
40
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" ]}
42
44
43
45
; ; Development tools
44
46
:dev {:dependencies [[pjstadig/humane-test-output " 0.10.0" ]]
Original file line number Diff line number Diff line change 8
8
[clojure.string :as str]
9
9
[orchard.java.classpath :as cp]
10
10
[orchard.misc :as misc]
11
- [orchard.java.resource :as resource])
11
+ [orchard.java.resource :as resource]
12
+ [orchard.util.io :as util.io])
12
13
(:import
13
14
(clojure.lang IPersistentMap)
14
15
(clojure.reflect Constructor Field JavaReflector Method)
421
422
(javadoc-base-urls 11 ))))))
422
423
path))
423
424
424
- ; ;; ## Initialization
425
- ; ;
426
- ; ; On startup, cache info for the most commonly referenced classes.
427
- (future
425
+ (defn- initialize-cache!* []
428
426
(doseq [class (->> (ns-imports 'clojure.core)
429
427
(map #(-> % ^Class val .getName symbol)))]
430
428
(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