Project

rack-mlog

0.0
No commit activity in last 3 years
No release in over 3 years
A rack middleware to log each HTTP request onto a MongoDB collection
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 1.5.1
>= 0

Runtime

>= 0
 Project Readme

rack-mlog¶ ↑

rack-mlog is a rack middleware to provide statistics and request logging via a MongoDB Database.

gem install rack-mlog

Example config.ru:

require 'rack/mongolog'

use Rack::MongoLog
run MyApp.new

Example config.ru with a custom MongoDB:

require 'rack/mongolog'

use Rack::MongoLog :uri => 'mongodb://user:pass@flame.mongohq.com:27051/mysite'
run MyApp.new

Since this is a rack middleware it is fully compatible with any other rack compatible framework such as sinatra, rails, etc. It also works on heroku with MongoHQ.

mlog Configuration¶ ↑

  • :uri - This is the URI of the MongoDB, such as: ‘mongodb://user:pass@flame.mongohq.com:27051/mysite`

  • :collection - To specify a collection to use, default is ‘mlog`

  • :map - This is a Hash including key’s to map into the Hash saved on the MongoDB collection, any maps here will be added to the default maps. This allows you to add into rack-mlog, such as adding a authenticated user onto the collection.

Example maps¶ ↑

  • :method => lambda { |env, status, headers, body| env },

  • :ajax? => lambda { |env, status, headers, body| env == ‘XMLHttpRequest’