Skip to content

Commit b89e1ec

Browse files
authored
Merge pull request #8499 from NBKelly/logs-destination-fixed
logs destination fixes
2 parents cf49dff + 94e4b88 commit b89e1ec

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/clj/web/logs.clj

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
[taoensso.timbre :as timbre]
44
[clojure.java.io :as io]))
55

6+
(def home (System/getProperty "user.home"))
7+
68
(def default-appender
79
{:enabled? true
810
:async? true
911
:min-level :info
1012
:output-fn timbre/default-output-fn
1113
:fn (fn [{:keys [level output_ context]}]
1214
(when-not (or (= level :error) (= level :fatal) (= (:type context) :moderator))
13-
(spit "logs/clojure.log" (str @output_ "\n") :append true)))})
15+
(spit (str home "/logs/jinteki-clojure.log") (str @output_ "\n") :append true)))})
1416

1517
(def exceptions-appender
1618
{:enabled? true
@@ -19,23 +21,23 @@
1921
:output-fn timbre/default-output-fn
2022
:fn (fn [{:keys [output_]}]
2123
(println @output_)
22-
(spit "logs/exceptions.log" (str @output_ "\n") :append true))})
24+
(spit (str home "/logs/jinteki-exceptions.log") (str @output_ "\n") :append true))})
2325

2426
(def mod-action-appender
2527
{:enabled? true
2628
:async? true
2729
:min-level :info
2830
:output-fn timbre/default-output-fn
2931
:fn (fn [{:keys [output_ context]}]
30-
(when (= (:type context) :moderator))
31-
(spit "logs/mod-actions.log" (str @output_ "\n") :append true))})
32+
(when (= (:type context) :moderator)
33+
(spit (str home "/logs/jinteki-mod-actions.log") (str @output_ "\n") :append true)))})
3234

3335
(defn timbre-init!
3436
[]
3537
(io/make-parents "logs/clojure.log")
3638
;; clojure.log and exceptions.log can be cleaned up between each run
37-
(when-let [f (io/file "logs/clojure.log")] (when (.exists f) (.delete f)))
38-
(when-let [f (io/file "logs/exceptions.log")] (when (.exists f) (.delete f)))
39+
(when-let [f (io/file (str home "/logs/jinteki-clojure.log"))] (when (.exists f) (.delete f)))
40+
(when-let [f (io/file (str home "/logs/jinteki-exceptions.log"))] (when (.exists f) (.delete f)))
3941
;; todo - back up the logs files or something like that
4042
;; maybe we can actually just have an indexed html that points to different log files?
4143
;; that would actually be sick as hell

0 commit comments

Comments
 (0)