Skip to content

Instantly share code, notes, and snippets.

@micha
Created October 6, 2016 21:58
Show Gist options
  • Save micha/d536bd42e686819f73457c409c971127 to your computer and use it in GitHub Desktop.
Save micha/d536bd42e686819f73457c409c971127 to your computer and use it in GitHub Desktop.
(ns gymir.main
(:require
[gymir
[worker :refer [start stop]]
[util :refer [with-stderr print-trace]]]))
(Thread/setDefaultUncaughtExceptionHandler
(reify Thread$UncaughtExceptionHandler
(uncaughtException [_ thread ex]
(with-stderr (prn :UNCAUGHT {:thread (.getName thread)}))
(print-trace ex))))
;; various logging things
(System/setProperty
"java.util.logging.SimpleFormatter.format" "%4$s: %5$s%6$s%n")
(def console-log
(-> (java.util.logging.Logger/getLogger "")
(.getHandlers)
(first)))
(.. (java.util.logging.Logger/getLogger "gymir.worker")
(setLevel java.util.logging.Level/ALL))
(.. (java.util.logging.Logger/getLogger "gymir.repl")
(setLevel java.util.logging.Level/ALL))
(.. (java.util.logging.Logger/getLogger "com.amazonaws.http")
(setLevel java.util.logging.Level/WARNING))
(.. (java.util.logging.Logger/getLogger "com.amazonaws.auth")
(setLevel java.util.logging.Level/SEVERE))
(.setLevel console-log java.util.logging.Level/ALL)
(.. (Runtime/getRuntime)
(addShutdownHook (Thread. #(do (stop) (.close console-log)))))
(defn -main
"Start gymir -- application entrypoint."
[& args]
(start))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment