|
3 | 3 | [taoensso.timbre :as timbre] |
4 | 4 | [clojure.java.io :as io])) |
5 | 5 |
|
| 6 | +(def home (System/getProperty "user.home")) |
| 7 | + |
6 | 8 | (def default-appender |
7 | 9 | {:enabled? true |
8 | 10 | :async? true |
9 | 11 | :min-level :info |
10 | 12 | :output-fn timbre/default-output-fn |
11 | 13 | :fn (fn [{:keys [level output_ context]}] |
12 | 14 | (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)))}) |
14 | 16 |
|
15 | 17 | (def exceptions-appender |
16 | 18 | {:enabled? true |
|
19 | 21 | :output-fn timbre/default-output-fn |
20 | 22 | :fn (fn [{:keys [output_]}] |
21 | 23 | (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))}) |
23 | 25 |
|
24 | 26 | (def mod-action-appender |
25 | 27 | {:enabled? true |
26 | 28 | :async? true |
27 | 29 | :min-level :info |
28 | 30 | :output-fn timbre/default-output-fn |
29 | 31 | :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)))}) |
32 | 34 |
|
33 | 35 | (defn timbre-init! |
34 | 36 | [] |
35 | 37 | (io/make-parents "logs/clojure.log") |
36 | 38 | ;; 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))) |
39 | 41 | ;; todo - back up the logs files or something like that |
40 | 42 | ;; maybe we can actually just have an indexed html that points to different log files? |
41 | 43 | ;; that would actually be sick as hell |
|
0 commit comments