Skip to content

Commit

Permalink
silence sl4f.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuernber committed Feb 16, 2019
1 parent 40559c2 commit 7d0e2c6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/tech/ml/utils.clj
Expand Up @@ -49,3 +49,13 @@
(reset! next-item-atom (next-item-fn))
entry)
(throw (NoSuchElementException.))))))))


(defn set-slf4j-log-level
"Set the slf4j log level. Safe to call if slf4j is not in the
classpath."
[level]
(try
((parallel/require-resolve 'tech.ml.utils.slf4j-log-level/set-log-level) level)
(catch Throwable e
:exception)))
19 changes: 19 additions & 0 deletions src/tech/ml/utils/slf4j_log_level.clj
@@ -0,0 +1,19 @@
(ns tech.ml.utils.slf4j-log-level
(:import [ch.qos.logback.classic Logger]
[ch.qos.logback.classic Level]))


(defn set-log-level
[log-level]
(.setLevel
(org.slf4j.LoggerFactory/getLogger
(Logger/ROOT_LOGGER_NAME))
(case log-level
:all Level/ALL
:debug Level/DEBUG
:trace Level/TRACE
:info Level/INFO
:warn Level/WARN
:error Level/ERROR
:off Level/OFF))
log-level)

0 comments on commit 7d0e2c6

Please sign in to comment.