Home > rack-mlog

rack-mlog

Rack-mlog is a project mainly written in Ruby, based on the MIT license.

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

= 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:[email protected]: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:[email protected]: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['REQUEST_METHOD'] },
  • :ajax? => lambda { |env, status, headers, body| env['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
Previous:wickit