An open API service indexing awesome lists of open source software.

https://github.com/strojure/slf4j-mdc

Clojure utility for SLF4J logging system's MDC (Mapped Diagnostic Context)
https://github.com/strojure/slf4j-mdc

clojure logging mdc slf4j

Last synced: 6 months ago
JSON representation

Clojure utility for SLF4J logging system's MDC (Mapped Diagnostic Context)

Awesome Lists containing this project

README

          

# slf4j-mdc

Clojure utility for SLF4J logging system's MDC (Mapped Diagnostic Context).

[![Clojars Project](https://img.shields.io/clojars/v/com.github.strojure/slf4j-mdc.svg)](https://clojars.org/com.github.strojure/slf4j-mdc)

## Design goals

* Helper functionality to work with MDC.

## Usage

```clojure
(ns readme.usage
(:require [clojure.tools.logging :as log]
[strojure.slf4j-mdc.core :as mdc]))

(defn- update-user
[user-id, data]
(with-open [_ (mdc/put-closeable "user-id" (str user-id))
_ (mdc/put-closeable "empty" nil)]
(log/debug "Update user" data)))

(comment
(update-user 100 {:name "Name"})
;; DEBUG readme.usage [ user-id=100 ]
;; - Update user {:name Name}

(with-open [_ (mdc/put-closeable "request-id" "64024bf5-862a-4e9f-a827-b924fc04f6d8")]
(update-user 100 {:name "Name"}))
;; DEBUG readme.usage [ request-id=64024bf5-862a-4e9f-a827-b924fc04f6d8, user-id=100 ]
;; - Update user {:name Name}
)
```