Skip to content

Releases: nberger/ring-logger

1.1.1

21 Jan 08:10
Compare
Choose a tag to compare

New features

  • Added :status-to-level-fn, which allows you to control the logging level of HTTP status codes in wrap-log-response.

Enhancements

  • Added support for async ring handlers
    • Async handlers were supported in 0.7, but support was dropped in 1.0.0.
    • This change should make it easy to migrate to 1.x from 0.7
  • Updated org.clojure/tools.logging dependency to 1.2.3 (thanks @CambodianCoder)

What's Changed

New Contributors

Full Changelog: 1.0.1...1.1.1

1.0.1

27 Apr 23:50
Compare
Choose a tag to compare

Fixes

  • Fix on wrap-log-request-params: StackOverflowException when passing handler only - #42 (@yanatan16)

1.0.0

27 Mar 12:37
Compare
Choose a tag to compare

This is a major, breaking-changes release

  • Logger protocol and messages multimethod ("printer") were replaced with :transform-fn and :log-fn options
  • No default coloring (coloring can be added through the transform-fn)
  • "Logs as data": Log messages are simple clojure maps now. This makes it easy to transform to different
    final representations: string, colored string, JSON, EDN, etc.

Some rationale behind this release: #30

Example using timbre and clansi for coloring:

  (require '[clansi.core :as ansi])
  (require '[timbre.core :as timbre])
  (require '[ring.logger :refer [wrap-with-logger]])
  (-> handler
      (wrap-with-logger {:log-fn (fn [{:keys [level throwable message]}]
                                   ;; log using timbre instead of clojure.tools.logging
                                   (timbre/log level throwable message))
                         :transform-fn (fn [log-item]
                                         (if (get-in log-item [:message :status])
                                           ;; colorize the status code
                                           (update-in log-item
                                                      [:message :status]
                                                      (fn [status]
                                                        (apply ansi/style
                                                          (str status)
                                                          (cond
                                                            (< status 300)  [:default]
                                                            (>= status 500) [:bright :red]
                                                            (>= status 400) [:red]
                                                            :else           [:yellow]))))
                                           log-item))}))

New features

  • Apart from wrap-with-logger, 3 additional middlewares are provided to make it easier to choose what to log:
    • wrap-log-request-start: logs the arrival of a request, adds :ring.logger/start-ms key to the request map
    • wrap-log-request-params: logs the parameters, using redaction to hide sensitive data
    • wrap-log-response: logs the response time and status, along with other data to identify the request. Uses
      :ring.logger/start-ms from the request map or calls (System/currentTimeMillis) by itself.

0.7.8

21 Mar 01:14
Compare
Choose a tag to compare

New features

  • Add option to exclude query-string from being logged - #29 (@pmensik)
  • Add asynchronous versions of the middleware - #26 (@grinderrz)

0.7.7

03 Feb 11:52
Compare
Choose a tag to compare

Bug fixes

  • Remove unnecessary println line - #22 - Thanks @singen!
  • Avoid reflection warning - #20 - Thanks @mtkp!

0.7.6

30 Mar 01:02
Compare
Choose a tag to compare

Enhancements

  • Redact cookies (because sensitive information might be in cookies) #19

Breaking changes

  • :redact-keys accepts only keywords now. Strings are not accepted anymore.

0.7.5

23 Oct 19:06
Compare
Choose a tag to compare

New features

  • Add ability to redact headers & params for logging

Dependencies

  • Bump down clojure dependency to 1.6.0

0.7.4

01 Oct 21:46
Compare
Choose a tag to compare

Bug fixes

  • Fix timing info in exception message

0.7.3

01 Oct 21:46
Compare
Choose a tag to compare
0.7.3 Pre-release
Pre-release

Bug fixes

  • Fix wrap-with-body-logger. It wasn't working at all.

0.7.2

21 Sep 21:25
Compare
Choose a tag to compare

New Features

  • Add :exceptions option to disable exception logging.
    Useful when already using ring.middleware.stacktrace

Enhancements

  • Generate one log message instead of two when an exception occurs.
  • Include colorized exception message in logged string.