NAME

Color Debug Messages - A way to add nicer output to your script.

DESCRIPTION

I got tired of plain output on STDOUT, and wanted a nicer way to add debug/informational messages to my scripts. This works with the idea that it is easier for our eyes to notice changes in color than changes in glyph/shape. A red error message is notices more easily than a “*****” prefix or similar.

To get this effect, we rely on Term::ANSIColor

Install

gem install color_debug_messages

Usage

The basic use of this script is very simple - you just include the module into your class, and call the various “puts” wrappers.

class Foo
  include ColorDebugMessages
  def bar(baz)
    debug "This is a debug message!"
  end
end

Which produces:

[Foo#bar] >>> This is a debug message!

The part in square-brackets at the beginning will be in read, which I unfortunately am having a hard time making RDoc produce.

The available message types, by default, are:

debug(msg)  # ">>>" prefix, in cyan
warn(msg)   # "**>" prefix, in red
info(msg)   # "-->" prefix, in green

These can be changed by adding lines like this to the top of your class:

class Foo
  include ColorDebugMessages
  color_debug_message_type :quux, '~', :blue

  def bar
    quux "Test message!"
  end
end

Which will produce yellow output, with the "~~>" prefix instead.

COPYRIGHT

Copyright © 2010 Brent Sanders. See LICENSE for details.