at91samd: add erase/secure commands, minor fix
[openocd.git] / tools / logger.pl
blobfb38f067d7d1f0ec36ee1a78936759d37cf92318
1 #!/usr/bin/perl
2 # logger.pl: masks long meaningless output with pretty lines of dots
3 # Details: 1) reads lines from STDIN and echos them on STDOUT,
4 # 2) print a '.' to STDERR every $N lines.
5 # 3) print a newline after a sequence of $C dots
7 use strict;
8 use warnings;
10 # make sure all output gets displayed immediately
11 $| = 1;
13 # TODO: add -n and -c options w/ zero checks)
14 # line and column limits
15 my $N = 10;
16 my $C = 72;
18 # current line and column counters
19 my $n = 0;
20 my $c = 0;
22 # read all lines from STDIN
23 while (<STDIN>)
25 # echo line to output
26 print STDOUT $_;
27 # echo line to console if it is important
28 if (/(Warning|Error)/) {
29 print STDERR "\n" if $c;
30 print STDERR $_;
31 $c = 0;
33 # only display progress every Nth step
34 next if ++$n % $N;
35 print STDERR ".";
36 # wrap at column C to provide fixed-width rows of dots
37 print STDERR "\n" unless ++$c % $C;
40 print STDERR "\n" if $c;