Small logging improvement
This commit is contained in:
parent
78ab11b1cd
commit
652f5d1744
5
deps.edn
5
deps.edn
|
@ -3,8 +3,5 @@
|
||||||
ring/ring-jetty-adapter {:mvn/version "1.11.0"}
|
ring/ring-jetty-adapter {:mvn/version "1.11.0"}
|
||||||
babashka/fs {:mvn/version "0.5.20"}
|
babashka/fs {:mvn/version "0.5.20"}
|
||||||
;; logs for jetty
|
;; logs for jetty
|
||||||
org.slf4j/slf4j-api {:mvn/version "2.0.9"}
|
org.slf4j/slf4j-simple {:mvn/version "2.0.11"}
|
||||||
ch.qos.logback/logback-classic {:mvn/version "1.4.11"}
|
|
||||||
net.logstash.logback/logstash-logback-encoder {:mvn/version "7.4"}
|
|
||||||
ch.codesmith/logger {:mvn/version "0.7.108"}
|
|
||||||
}}
|
}}
|
||||||
|
|
51
statyk
51
statyk
|
@ -12,10 +12,7 @@
|
||||||
ring/ring-jetty-adapter {:mvn/version "1.11.0"}
|
ring/ring-jetty-adapter {:mvn/version "1.11.0"}
|
||||||
babashka/fs {:mvn/version "0.5.20"}
|
babashka/fs {:mvn/version "0.5.20"}
|
||||||
;; logs for jetty
|
;; logs for jetty
|
||||||
org.slf4j/slf4j-api {:mvn/version "2.0.9"}
|
org.slf4j/slf4j-simple {:mvn/version "2.0.11"}
|
||||||
ch.qos.logback/logback-classic {:mvn/version "1.4.11"}
|
|
||||||
net.logstash.logback/logstash-logback-encoder {:mvn/version "7.4"}
|
|
||||||
ch.codesmith/logger {:mvn/version "0.7.108"}
|
|
||||||
}}
|
}}
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -171,7 +168,7 @@ exec clojure $OPTS -Sdeps "$DEPS" -M "$0" "$@"
|
||||||
|
|
||||||
(defn generate-static-files
|
(defn generate-static-files
|
||||||
[]
|
[]
|
||||||
(doseq [src-file (file-seq (:source-directory config))]
|
(doseq [src-file (file-seq (io/file (:source-directory config)))]
|
||||||
(let [{:keys [ext dst-file]} (dst-file-name-and-ext src-file)]
|
(let [{:keys [ext dst-file]} (dst-file-name-and-ext src-file)]
|
||||||
(when (is-newer? src-file dst-file)
|
(when (is-newer? src-file dst-file)
|
||||||
(build src-file dst-file ext)))))
|
(build src-file dst-file ext)))))
|
||||||
|
@ -182,7 +179,7 @@ exec clojure $OPTS -Sdeps "$DEPS" -M "$0" "$@"
|
||||||
["Usage: statyk [<options>] <command> [<args>]"
|
["Usage: statyk [<options>] <command> [<args>]"
|
||||||
"Where commands:"
|
"Where commands:"
|
||||||
"- serve serve the directory _site"
|
"- serve serve the directory _site"
|
||||||
"- gen generate the files from the sources"
|
"- build build the site from the sources"
|
||||||
"- clean delete generated files in _site"]))
|
"- clean delete generated files in _site"]))
|
||||||
(System/exit 0))
|
(System/exit 0))
|
||||||
|
|
||||||
|
@ -207,8 +204,27 @@ exec clojure $OPTS -Sdeps "$DEPS" -M "$0" "$@"
|
||||||
(cp-resource ".statyk" f))
|
(cp-resource ".statyk" f))
|
||||||
(doseq [f ["index.html"
|
(doseq [f ["index.html"
|
||||||
"post.html"]]
|
"post.html"]]
|
||||||
(cp-resource (:templates-directory config) f))
|
(cp-resource (:templates-directory config) f)))
|
||||||
)
|
|
||||||
|
(defn do-command
|
||||||
|
[command options]
|
||||||
|
(case command
|
||||||
|
"serve" (do
|
||||||
|
(println "Serve: http://127.0.0.1:13375")
|
||||||
|
(run-jetty serve-dest-dir-handler
|
||||||
|
{:port 13375
|
||||||
|
:host "127.0.0.1"}))
|
||||||
|
"build" (generate-static-files)
|
||||||
|
"init" (init-site options)
|
||||||
|
(show-help)
|
||||||
|
(err! (format "unknown command %s" command))))
|
||||||
|
|
||||||
|
(defn initialized?
|
||||||
|
"Returns false if the current directory does not conform to an initalized statyk dir."
|
||||||
|
[]
|
||||||
|
(and
|
||||||
|
(fs/exists? (:source-directory config))
|
||||||
|
(fs/exists? (:dest-directory config))))
|
||||||
|
|
||||||
(defn -main [& args]
|
(defn -main [& args]
|
||||||
(let [{:keys [options arguments summary errors]
|
(let [{:keys [options arguments summary errors]
|
||||||
|
@ -218,17 +234,14 @@ exec clojure $OPTS -Sdeps "$DEPS" -M "$0" "$@"
|
||||||
(doseq [err errors]
|
(doseq [err errors]
|
||||||
(pr-err! err)
|
(pr-err! err)
|
||||||
(System/exit 1)))
|
(System/exit 1)))
|
||||||
(let [command (first arguments)]
|
(if-let [command (first arguments)]
|
||||||
(condp = command
|
(do-command command options)
|
||||||
"serve" (do
|
(do
|
||||||
(println "Serve: http://127.0.0.1:13375")
|
(when-not (initialized?)
|
||||||
(run-jetty serve-dest-dir-handler
|
(do-command "init" options))
|
||||||
{:port 13375
|
|
||||||
:host "127.0.0.1"}))
|
(future (do-command "serve" options))
|
||||||
"gen" (generate-static-files)
|
(do-command "watch" options)))))
|
||||||
"init" (init-site options)
|
|
||||||
(show-help)
|
|
||||||
(err! (format "unknown command %s" command))))))
|
|
||||||
|
|
||||||
(apply -main *command-line-args*)
|
(apply -main *command-line-args*)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue