No commit activity in last 3 years
No release in over 3 years
Module to add colorful debug messages to a class.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

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.