| 1 | # this is only intended as an example. Most people have their own ideas of | ||
| 2 | # what's important and what isn't in a log, so you'll want to highlight lines | ||
| 3 | # differently. | ||
| 4 | |||
| 5 | package App::Tel::Color::CiscoLog; | ||
| 6 | 2 | ▶ | use parent 'App::Tel::Color::Base'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 2 | ▶ | use Term::ANSIColor; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | =head2 colorize | ||
| 12 | |||
| 13 | my $output = $self->colorize($input); | ||
| 14 | |||
| 15 | colors a line of input | ||
| 16 | |||
| 17 | =cut | ||
| 18 | |||
| 19 | 1 | ▶ | sub colorize { |
|
Subroutine
colorize: called CC=1 SCAR=0.0
Pod
documented
| |||
| 20 | 1 | my ($self, $text) = @_; | |
| 21 | 0 | $text =~ s/((%SEC-6-IPACCESSLOGS|%SNMP-3-AUTHFAIL|%PFINIT-SP-5-CONFIG_SYNC).*)/sprintf("%s", colored($1, 'green'))/eg; | |
| 22 | 1 | $text =~ s/((%SYS-5-CONFIG_I|%CONTROLLER-5-UPDOWN).*)/sprintf("%s", colored($1, 'red'))/eg; | |
| 23 | 1 | return $text; | |
| 24 | } | ||
| 25 | |||
| 26 | 2 | 1; | |