Project

tocsin

0.0
No commit activity in last 3 years
No release in over 3 years
Supports wrapping code that you want to be alerted of failures in, as well as sending notifications through the same mechanism.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

>= 0
>= 3.0.0
>= 0
 Project Readme

Tocsin

Tocsin is a library designed to simplify the task of notifying interested parties about your site's operation. You may already be tracking errors through New Relic, but not all errors are created equal -- there are probably parts of your site where an exception is a bigger problem than random link surfing that throws 404s. Tocsin will inform you when these parts of your site break, or when important events happen, or really just whenever you configure it to notify you.

Currently, Tocsin works only in Rails 3, and supports notification via email.

Build Status

Installation

Add Tocsin to your Gemfile:

gem 'tocsin'

Update your bundle:

bundle install

Use the provided Rake task to generate the migration and model needed by Tocsin. (Angry at the lack of normalization? Install lookup_by and rewrite the migration and model to use it; Tocsin won't even notice.)

rake tocsin:install

Lastly, configure Tocsin to be useful. Create an initializer in config/initializers/tocsin.rb that looks something like this:

Tocsin.configure do |c|
  c.from_address = 'me@mysite.com'

  c.notify 'you@gmail.com', :of => { :category => /user_registrations/ }, :by => :email
  c.notify ['you@gmail.com', 'sales@mysite.com'], :of => { :category => /new_sales/ } # N.B. 'email' is the default nofifier.
  c.notify 'ops@mysite.com', :of => { :severity => /critical/ } # Values in the :of hash should be regexes.
end

Usage

In anywhere you want to send yourself a notification:

Tocsin.notify :category => :user_registrations,
              :message => "User #{user.name} registered at #{Time.now}!"

If you want to sound the alarm:

begin
  # ...
rescue => e
  Tocsin.raise_alert  e, :category => :user_registrations,
                         :severity => :critical,
                         :message => "An error occurred when a user tried to sign up!"
end

In any code you want to watch for explosions:

Tocsin.watch! :category => :important_stuff, :severity => :critical, :message => "Error doing important stuff!" do
  Important::Stuff.do!
end

License

MIT. See LICENSE.