~willvaughn/kata

d5ebcc0d566197bcc6048ef7d197554073a23ea9 — William Vaughn 1 year, 11 months ago 436a03d
exercism log-levels solution
1 files changed, 7 insertions(+), 3 deletions(-)

M exercism/clojure/log-levels/src/log_levels.clj
M exercism/clojure/log-levels/src/log_levels.clj => exercism/clojure/log-levels/src/log_levels.clj +7 -3
@@ 5,16 5,20 @@
  "Takes a string representing a log line
   and returns its message with whitespace trimmed."
  [s]
  )
  (-> s
      (str/split #":")
      second
      str/trim))

(defn log-level
  "Takes a string representing a log line
   and returns its level in lower-case."
  [s]
  )
  (let [[_ level] (re-find #"^\[(\w+)\]" s)]
    (str/lower-case level)))

(defn reformat
  "Takes a string representing a log line and formats it
   with the message first and the log level in parentheses."
  [s]
  )
  (format "%s (%s)" (message s) (log-level s)))