0.0
No commit activity in last 3 years
No release in over 3 years
A simple logger for mongoid
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Mongoid::Clerk

Build Status

Code Climate

A simple logger for Mongoid.

Installation

Add this line to your application's Gemfile:

gem 'mongoid-clerk', :require => 'clerk'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mongoid-clerk

Usage

Include Clerk::Logger in your model, then log anything with log(). The first argument is the message and the second the level.

You can add default fields to your log entry by adding clerk_always_include this method accepts an array of fields it should include, or a hash if you want to rename a field.

Clerk adds a polymorphic relation to the model log_items so you can scope log entries on this model.

Clerk::Log behaves like a regular mongoid model for easy access to your log entries.

example model:

class User
  include Clerk::Logger

  field :name
  field :address

  clerk_always_include :name, :address => :place

  def something
    log('Something went wrong!', :error)
  end

end

Testing

Start foreman and run the tests with rake

Contributing

  1. Fork it
  2. Fix it
  3. Push it
  4. Pullreq it