Get Version


→ ‘watcher’



sudo gem install watcher

The basics

A simple example demonstrating multiple embedded levels, and how the
inside block simply logs the error so that the second puts statement still executes.

# create Watcher instance with defaults
$watcher = Watcher.create

$watcher.verbose("doing something dangerous") do
  puts "be careful..."
  $watcher.debug("going to do something very dangerous", :failure => :warn) do
    raise "ouch!"
  puts "that wasn't so bad... just a log entry!"

h2. Demonstration of usage

A more complicated example of sending a reference to a Proc to attempt
to recover from an condition.

# create Watcher instance with slightly modified defaults
$watcher = Watcher.create(:output => log_file)

$watcher.debug("starting #{File.basename($0)}") do
  # Look for CONFIG_PATH.  If not found, log warning then re-write it
  params = {:tries => 2, :failure => :error,
            :proc => lambda { |e| write_config(config_path) }}
  msg = "ensuring existance of config file [#{config_path}]"
  $watcher.verbose(msg, params) do
    raise "file not found" unless File.file?(File.expand_path(config_path))

  # invoke utility, which uses $watcher as well
  fsc = => config_path)
  fsc.check_file_systems(:all => all_flag, :remount => remount_flag)

if email_flag and ($watcher.errors > 0 or $watcher.warnings > 0)
  $watcher.send_email(email, 'FAIL: Required filesystems are not mounted')


TODO – create Google Group – watcher

How to submit patches

Read the 8 steps for fixing other people’s code and for section 8b: Submit patch to Google Groups, use the Google Group above.

TODO – pick SVN or Git instructions

The trunk repository is svn:// for anonymous access.


You can fetch the source from either:

TODO – You can not created a RubyForge project, OR have not run rubyforge config
yet to refresh your local rubyforge data with this projects’ id information.

When you do this, this message will magically disappear!

Or you can hack website/index.txt and make it all go away!!

git clone git://

TODO – add “github_username: username” to ~/.rubyforge/user-config.yml and newgem will reuse it for future projects.

git clone git://

Build and test instructions

Sorry, no unit tests yet…

cd watcher
rake install_gem


This code is free to use under the terms of the Simplified BSD license.


Comments are welcome. Send an email to Karrick McDermott via the forum

Karrick McDermott, 30th July 2008
Theme extended from Paul Battley