JOLT_TRACE: one case-insensitive off-check for both enable paths
Review turned up that the disable vocabulary was the exact lowercase strings "0"/"false"/"no", so JOLT_TRACE=off (or FALSE, No, n) fell through and ENABLED tracing — the opposite of intent — and the whole-run and dev-mode checks disagreed on the empty string. Fold both into one jolt-trace-env-off? predicate (case-insensitive, incl. off/n); empty/unset carries no signal (dev still traces, a whole run still doesn't).
This commit is contained in:
parent
7167af4830
commit
79002526bb
1 changed files with 17 additions and 8 deletions
|
|
@ -110,24 +110,33 @@
|
|||
;; older seed during the first re-mint pass.
|
||||
(let ((scv (var-deref "jolt.backend-scheme" "set-var-cache!")))
|
||||
(when (procedure? scv) (scv #t)))
|
||||
;; JOLT_TRACE is a falsey value (case-insensitive) — the single predicate both the
|
||||
;; dev-mode enable and the whole-run enable consult, so "off" never accidentally
|
||||
;; means "on". An empty / unset value is NOT falsey here — it carries no signal, so
|
||||
;; dev mode still traces and a whole run still doesn't.
|
||||
(define (jolt-trace-env-off? e)
|
||||
(and (string? e)
|
||||
(let ((s (string-downcase e)))
|
||||
(or (string=? s "0") (string=? s "false") (string=? s "no")
|
||||
(string=? s "off") (string=? s "n")))))
|
||||
;; Tail-frame history. Turning it on makes the emitter add a per-fn history push to
|
||||
;; every fn compiled AFTERWARD, and allocates this thread's ring. Suppressed when
|
||||
;; JOLT_TRACE is explicitly falsey, so JOLT_TRACE=0 disables it even in dev mode.
|
||||
;; JOLT_TRACE is a falsey value, so JOLT_TRACE=0 / off / no disables it in dev mode.
|
||||
(define (jolt-enable-trace!)
|
||||
(let ((e (getenv "JOLT_TRACE")))
|
||||
(unless (and e (member e '("0" "false" "no")))
|
||||
(let ((stf (var-deref "jolt.backend-scheme" "set-trace-frames!")))
|
||||
(when (procedure? stf) (stf #t)))
|
||||
(jolt-trace-enable!))))
|
||||
(unless (jolt-trace-env-off? (getenv "JOLT_TRACE"))
|
||||
(let ((stf (var-deref "jolt.backend-scheme" "set-trace-frames!")))
|
||||
(when (procedure? stf) (stf #t)))
|
||||
(jolt-trace-enable!)))
|
||||
;; Exposed so the REPL / nREPL entrypoints (jolt.main, jolt.nrepl) can turn tracing
|
||||
;; on for REPL-driven development without the user setting JOLT_TRACE. Because the
|
||||
;; push is baked in at compile time, only code compiled after this call is traced —
|
||||
;; which is exactly the code you eval / reload in a live session.
|
||||
(def-var! "jolt.host" "enable-trace!" jolt-enable-trace!)
|
||||
;; Explicit opt-in for a whole run (JOLT_TRACE=1): enable at load, BEFORE any app
|
||||
;; namespace is compiled, so a plain `-M:run` traces the app's own code too.
|
||||
;; namespace is compiled, so a plain `-M:run` traces the app's own code too. Only an
|
||||
;; affirmative value (set, non-empty, not falsey) forces it on here.
|
||||
(let ((e (getenv "JOLT_TRACE")))
|
||||
(when (and e (not (member e '("0" "false" "no" "")))) (jolt-enable-trace!)))
|
||||
(when (and e (fx>? (string-length e) 0) (not (jolt-trace-env-off? e))) (jolt-enable-trace!)))
|
||||
|
||||
;; (with-meta sym m) -> sym, else x — an (ns ^:no-doc name …) yields the name with
|
||||
;; reader metadata as a with-meta form; strip it to read the bare ns symbol.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue