default log level
This commit is contained in:
parent
4c5e7cc86d
commit
ea62c99853
2 changed files with 15 additions and 8 deletions
|
|
@ -7,7 +7,8 @@
|
||||||
[sci.core :as sci]))
|
[sci.core :as sci]))
|
||||||
|
|
||||||
(def sci-ns (sci/create-ns 'babashka.tasks nil))
|
(def sci-ns (sci/create-ns 'babashka.tasks nil))
|
||||||
(def log-level (sci/new-dynamic-var '*-log-level* :info {:ns sci-ns}))
|
(def default-log-level :error)
|
||||||
|
(def log-level (sci/new-dynamic-var '*-log-level* default-log-level {:ns sci-ns}))
|
||||||
(def task-name (sci/new-dynamic-var '*-task-name* nil {:ns sci-ns}))
|
(def task-name (sci/new-dynamic-var '*-task-name* nil {:ns sci-ns}))
|
||||||
|
|
||||||
(defn log-info [& strs]
|
(defn log-info [& strs]
|
||||||
|
|
@ -74,9 +75,8 @@
|
||||||
cmd (into cmd args)
|
cmd (into cmd args)
|
||||||
local-log-level (:log-level opts)]
|
local-log-level (:log-level opts)]
|
||||||
(sci/binding [log-level (or local-log-level @log-level)]
|
(sci/binding [log-level (or local-log-level @log-level)]
|
||||||
|
(apply log-info (cons "clojure" cmd))
|
||||||
(apply log-info cmd)
|
(exit-non-zero (deps/clojure cmd (merge default-opts opts))))))
|
||||||
(exit-non-zero (p/process cmd (merge default-opts opts))))))
|
|
||||||
|
|
||||||
(defn -wait [res]
|
(defn -wait [res]
|
||||||
(when res
|
(when res
|
||||||
|
|
@ -191,11 +191,11 @@
|
||||||
(conj order task-name))
|
(conj order task-name))
|
||||||
order))))))
|
order))))))
|
||||||
|
|
||||||
(defn assemble-task [task-name parallel?]
|
(defn assemble-task [task-name parallel? log-level]
|
||||||
(let [task-name (symbol task-name)
|
(let [task-name (symbol task-name)
|
||||||
bb-edn @bb-edn
|
bb-edn @bb-edn
|
||||||
tasks (get bb-edn :tasks)
|
tasks (get bb-edn :tasks)
|
||||||
log-level (or (:log-level tasks) :info)
|
log-level (or log-level (:log-level tasks) default-log-level)
|
||||||
task (get tasks task-name)]
|
task (get tasks task-name)]
|
||||||
(if task
|
(if task
|
||||||
(let [m? (map? task)
|
(let [m? (map? task)
|
||||||
|
|
|
||||||
|
|
@ -415,9 +415,14 @@ When no eval opts or subcommand is provided, the implicit subcommand is repl.")
|
||||||
args (seq args)]
|
args (seq args)]
|
||||||
(if args
|
(if args
|
||||||
(let [fst (first args)]
|
(let [fst (first args)]
|
||||||
(if (= "--parallel" fst)
|
(case fst
|
||||||
|
"--parallel"
|
||||||
(recur (assoc opts-map :parallel-tasks true)
|
(recur (assoc opts-map :parallel-tasks true)
|
||||||
(next args))
|
(next args))
|
||||||
|
"--log-level"
|
||||||
|
(let [args (next args)]
|
||||||
|
(recur (assoc opts-map :log-level (keyword (first args)))
|
||||||
|
(next args)))
|
||||||
(assoc opts-map :run fst :command-line-args (next args))))
|
(assoc opts-map :run fst :command-line-args (next args))))
|
||||||
opts-map)))
|
opts-map)))
|
||||||
|
|
||||||
|
|
@ -691,7 +696,9 @@ When no eval opts or subcommand is provided, the implicit subcommand is repl.")
|
||||||
"-main")]
|
"-main")]
|
||||||
[[(format "(ns user (:require [%1$s])) (apply %1$s/%2$s *command-line-args*)"
|
[[(format "(ns user (:require [%1$s])) (apply %1$s/%2$s *command-line-args*)"
|
||||||
ns var-name)] nil])
|
ns var-name)] nil])
|
||||||
run (tasks/assemble-task run (:parallel-tasks cli-opts))
|
run (tasks/assemble-task run
|
||||||
|
(:parallel-tasks cli-opts)
|
||||||
|
(:log-level cli-opts))
|
||||||
file (try [[(read-file file)] nil]
|
file (try [[(read-file file)] nil]
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(error-handler e {:expression expressions
|
(error-handler e {:expression expressions
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue