Hatchet

Ruby logging library that provides the ability to add class/module specific filters

View the Project on GitHub gshutler/hatchet

Navigation


Build status


Hosted on GitHub Pages — Theme by orderedlist

Sinatra Installation

Bundler-Enabled Applications

Add this line to your application’s Gemfile to get Hatchet from RubyGems.org:

gem 'hatchet'

And then execute:

$ bundle

If you are using Bundler to require your gems then Hatchet should now be available. Otherwise, you will need to require the Hatchet gem explicitly:

require 'hatchet'

Non-Bundler Applications

First you must install the gem from RubyGems.org:

$ gem install hatchet

Then you must require the gem from with your application:

require 'hatchet'

Helper Registration

Hatchet comes with the hook required to add itself as a helper. Once you have required the Hatchet gem you can register Hatchet as a helper:

register Hatchet

Alternatively, if you are using a class-based style of application you can include it in the individual classes:

class MyApp < Sinatra::Base
  include Hatchet
end

Configuration

Configuration is done via the standard configuration mechanism. Where this is done depends on how you have laid out your application but you should ensure that Hatchet is configured before you try and use it to log messages.

Caveats

When logging messages you may need to use the log alias as Sinatra defines its own logger method.