clog, colorful Ruby on Rails debug statements

I’m publishing yet another puny Ruby on Rails plugin.

http://github.com/kswope/clog

clog == “color log”

This blog post is mostly a repeat of the gem’s rdoc but with dazzling color pictures!

Gemfile

  gem "clog"

You change the defaults in environment.rb just like rails 2x but without the require.

Flag

No arguments outputs a “flag” to the log

clog

Single argument

  clog var

Tagged argument

First argument must be a symbol, which outputs before second argument.

  clog :var, var

Multiple arguments

Will output each on its own line.

  clog Object.new, Kernel, RUBY_VERSION, :a_symbol

Changing color

Clog.colors(background, forground=white)

Choices- :black, :red, :green, :yellow, :blue, :magenta, :cyan, :white

  Clog.colors(:blue)
  Clog.colors(:black, yellow)

Default is red background, white foreground.

Max width

clog figures out when its appropriate to place additional information (line number, calling method, etc) on the right of the output or below it on the next line. Think of maxwidth as representing the width of your terminal window. The default is 150

  Clog.maxwidth(100)

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s