Colortail Gem

What does ColorTail do for me?

ColorTail provides a cool way for you to configure how logfiles (or any other files for that matter) look when you tail them.

Install the gem

[root@web1 ~]# gem install colortail
Successfully installed spruz-0.1.0
Successfully installed file-tail-1.0.5
Successfully installed colortail-0.1.3
3 gems installed
Installing ri documentation for spruz-0.1.0...
Installing ri documentation for file-tail-1.0.5...
Installing ri documentation for colortail-0.1.3...
Installing RDoc documentation for spruz-0.1.0...
Installing RDoc documentation for file-tail-1.0.5...
Installing RDoc documentation for colortail-0.1.3...

Using ColorTail

By default, ColorTail does absolutely nothing other than just tail a file normally (similar to the trust old unix tool ‘tail -f’). But what good what writing a gem be if it just mimiced existing functionality.

Conifguring ColorTail

Configuring ColorTail is easy. In your home directory, create a file .colortailrc. This file will contain a group of ruby arrays similar to the ones laid out in the example config examples/colortail.rb. These arrays are called groups. Any group can be loaded via the command line using the -g switch (more on this below).

The standard configuration file is .colortailrc. It needs to be in the format of a Ruby hash.

The full list of choices for colors and combinations are listed below.

Colors

  • none – Yes you can have no color. This means display normally.
  • black
  • red
  • green
  • yellow
  • blue
  • magenta – (purple-ish)
  • cyan
  • white

Attributes

  • bright
  • dim
  • underscore
  • blink
  • reverse
  • hidden – simply don’t show the text

Configuration Example

The example given in the configuration file is good for tailing a syslog file that has lines that are naemd with their syslog level. There are a lot of potential uses. Check the wiki page of example groupings to see how others are using ColorTail.

Usage

Using ColorTail is similar to using tail. The main assumption is that you will always be indefinitely tail’ing a file.

Tailing with groups

The command below will tail the /var/log/messages file using the syslog group. The example config examples/colortail.rb shows a syslog grouping that is used in command below:

# colortail -g syslog /var/log/messages

Caveats and Intended Behaviors

ColorTail intentionally does not die when a file specified on the command line doesn’t exist.

Additional Information