ring-logger-onelog
OneLog implementation for ring-logger
ring.middleware.logger
Migration fromThe migration is pretty straightforward:
- Replace dependency in
project.clj
from[ring.middleware.logger "0.5.0"]
to[ring-logger-onelog "0.7.6"]
- Replace the require from
[ring.middleware.logger :as logger]
to[ring.logger.onelog :as logger]
- Pass options to
wrap-with-logger
using a proper map instead of keyword arguments.
Usage
In your project.clj
, add the following dependencies:
[ring-logger-onelog "0.7.6"]
Add the middleware to your stack, using the onelog implementation. It's similar to using the default ring-logger, but requiring the onelog namespace:
(ns foo
(:require [ring.adapter.jetty :as jetty]
[ring.logger.onelog :as logger.onelog]))
(defn my-ring-app [request]
{:status 200
:headers {"Content-Type" "text/html"}
:body "Hello world!"})
(jetty/run-jetty (logger.onelog/wrap-with-logger my-ring-app) {:port 8080})
ring-logger
Differences from plainEach request is assigned a random 4-hex-digit ID, so that different log messages pertaining to the same request can be cross-referenced.
These IDs are printed in random ANSI colors by default, for easy visual correlation of log messages while reading a log file.
- Q: I don't want ANSI colors, how can I remove them?
- A: Use the
:printer :no-color
option when creating the logger:
(logger.onelog/wrap-with-logger my-ring-app {:printer :no-color})
Log Levels
The logger logs at INFO
level by default. More verbose information is logged when the logger is at DEBUG
level.
We can use OneLog's convenience methods to change the log level:
(onelog.core/set-debug!)
(onelog.core/set-info!)
(onelog.core/set-warn!)
Contributing
Pull requests, issues and any feedback are all welcome!
License
Copyright © 2015 Nicolás Berger, 2012-2014 Paul Legato
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.