Sha256: 2cad638e6bed2c62c44f197f69d3c7123eae6f6ef3cdc776ac8230d037610cf7

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

# MongoRequestLogger

Log requests in a structured format to MongoDB.

## Installation

Add this line to your application's Gemfile:

    gem 'mongo_request_logger'

## Usage with Rails

Create config/logger.yml containing something like the following:

    development:
      host: localhost
      database: your_app_logs_production_dev
      capsize: 100  # megabytes

    production:
      host: localhost
      database: your_app_logs_production
      username: your_app_logs_production
      password: password
      capsize: 1024 # megabytes

Routes for log viewer

    mount MongoRequestLogger::Viewer, :at => "log"



## Usage with other Rack-based frameworks (Sinatra, etc)

In config.ru, or where appropriate:

    require 'moped'

    config = {
        database: 'my_log_db',
        collection: 'log',
        capsize: 100, # megabytes
    }

    adapter = MongoRequestLogger::Adapters::Moped.new(config)
    logger = MongoRequestLogger::Logger.new(adapter, "myapp.log")
    MongoRequestLogger::Rack.logger = loggger

    use MongoRequestLogger::Rack

    run MyApp

## Ignoring paths

Often you want some requests not to be logged, for example assets files. This can be done by specifying the prefixes
to be ignored:

    MongoRequestLogger::Rack.ignore_prefixes << '/assets/'

## Usage with resque

Extend from MongoRequestLogger::LoggedJob, to have each job logged as if it was a request.

    class MyJob
        extend MongoRequestLogger::LoggedJob

        def perform(args)
           # ...
        end
    end

## License

All code is under the MIT licence, see LICENSE.txt.

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongo_request_logger-0.2.2 README.md
mongo_request_logger-0.2.1 README.md
mongo_request_logger-0.2.0 README.md