Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@
:plugins [[jonase/eastwood "1.4.3" :exclusions [org.clojure/clojure]]
[org.openvoxproject/i18n ~i18n-version]]

:eastwood {:ignored-faults {:reflection {puppetlabs.trapperkeeper.logging [{:line 92}]
puppetlabs.trapperkeeper.internal [{:line 177}]
puppetlabs.trapperkeeper.testutils.logging true
:eastwood {:ignored-faults {:reflection {puppetlabs.trapperkeeper.testutils.logging true
puppetlabs.trapperkeeper.testutils.logging-test true
puppetlabs.trapperkeeper.services.nrepl.nrepl-service-test true
puppetlabs.trapperkeeper.plugins-test true}
Expand Down
10 changes: 8 additions & 2 deletions src/puppetlabs/trapperkeeper/internal.clj
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,14 @@
(log/warn (i18n/trs "Unable to connect to NOTIFY_SOCKET {0}"
(pr-str socket-path)))))))))

;;; Messages sent to the SystemD socket to indicate various service states.
;;; See the "Type=" section of the man page for "systemd.service" for schema:
;;;
;;; https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#Type=
(defn notice-service-ready [] (maybe-notify-systemd "READY=1\n"))
(defn notice-service-reloading [] (maybe-notify-systemd "RELOADING=1\n"))
(defn notice-service-reloading []
(maybe-notify-systemd
(str "RELOADING=1\nMONOTONIC_USEC=" (quot (System/nanoTime) 1000) "\n")))
(defn notice-service-stopping [] (maybe-notify-systemd "STOPPING=1\n"))

;; This is (eww) a global variable that holds a reference to all of the running
Expand Down Expand Up @@ -174,7 +180,7 @@
(if (sequential? (:error data))
(let [missing-services (keys (ks/filter-map
(fn [_ v] (= v 'missing-required-key))
(.error (first (:error data)))))]
(.error ^schema.utils.NamedError (first (:error data)))))]
(if (= 1 (count missing-services))
(throw (RuntimeException.
(i18n/trs "Service ''{0}'' not found" (first missing-services))))
Expand Down
13 changes: 12 additions & 1 deletion src/puppetlabs/trapperkeeper/logging.clj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
(.toInt ^Level level))
(.setLevel root level)))))

(defn- do-configure
"Calls the appropriate overload of `doConfigure` for the runtime type of
`logging-conf`, so that the call can be resolved without reflection."
[^JoranConfigurator configurator logging-conf]
(condp instance? logging-conf
java.io.File (.doConfigure configurator ^java.io.File logging-conf)
java.io.InputStream (.doConfigure configurator ^java.io.InputStream logging-conf)
java.net.URL (.doConfigure configurator ^java.net.URL logging-conf)
org.xml.sax.InputSource (.doConfigure configurator ^org.xml.sax.InputSource logging-conf)
(.doConfigure configurator ^String logging-conf)))

(defn configure-logger!
"Reconfigures the current logger based on the supplied configuration.

Expand All @@ -89,7 +100,7 @@
context (logging-context)]
(.setContext configurator context)
(.reset context)
(.doConfigure configurator logging-conf)))
(do-configure configurator logging-conf)))

(defn configure-logging!
"Takes a file path, url, file, InputStream, or InputSource which can
Expand Down