Hi,

Might be useful to add it to the ext dir
Ohad

On Wed, Sep 8, 2010 at 8:34 AM, Amos Shapira <[email protected]> wrote:

> Hi,
>
> We find the "color-coded" puppet logs very useful, but they are not
> coloured when logged to a file.
>
> Here is a small Perl script to add the color back when reading that
> file. I'd like to upload it to the Wiki but not sure where would it
> fit (and didn't find the way to add a new page).
>
> I offer it under GPL v3.
>
> #!/usr/bin/perl
>
> # colorpuppetlog: colorise puppet log according to the severity
> mentioned in the message
>
> # Copyright (c) Amos Shapira, September 8th 2010.
> # Licence: GPLv3
>
> use strict;
> use warnings;
> use Term::ANSIColor;
>
> my %colormap = (
>  'info' => 'green',
>  'notice' => 'cyan',
>  'err' => 'magenta',
>  'warning' => 'yellow');
>
> my $color = 'reset';
>
> while (<>)
> {
>  my $newcolor;
>  if (/ \((info|notice|err|warning)\): /)
>  {
>     $newcolor = $colormap{$1};
>  }
>  else
>  {
>     $newcolor = 'reset';
>  }
>
>  if ($newcolor ne $color)
>  {
>     $color = $newcolor;
>     print color($color);
>  }
>  print;
> }
>
> print color 'reset';
>
> exit 0;
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<puppet-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to