Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swlkr/bunyan
A simple logging ring middleware
https://github.com/swlkr/bunyan
clojure logger logging middleware ring ring-middleware
Last synced: about 2 months ago
JSON representation
A simple logging ring middleware
- Host: GitHub
- URL: https://github.com/swlkr/bunyan
- Owner: swlkr
- License: mit
- Created: 2015-12-28T07:40:47.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-29T06:08:42.000Z (about 9 years ago)
- Last Synced: 2024-07-05T13:47:23.632Z (6 months ago)
- Topics: clojure, logger, logging, middleware, ring, ring-middleware
- Language: Clojure
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
bunyan
======================Ring middleware to log the http method, url, status code and duration of each request to stdout.
Pull requests are welcome!
Usage
-----In your `project.clj`, add the following dependency:
```clojure
[bunyan "0.1.1"]
```Then, add the middleware to your stack.
```clojure
(ns foo
(:require [...]
[org.httpkit.server :refer [run-server]]
[bunyan.core :as bunyan]))...
(def app
(-> (handler/api app-routes)
(bunyan/wrap-with-logger)))(defn -main [& args]
(run-server app {:port config/port}))
(println (str "Server running on port " config/port))
```Example Logs
-----------```bash
GET / 200 7ms # 200s are green
GET /redirect 300 7ms # 300s are yellow
POST / 404 0ms # 400s are yellow too
GET /posts 500 1ms # 500s are red
````