You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
917 B

  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
  6. use strict;
  7. use warnings;
  8. # make sure all output gets displayed immediately
  9. $| = 1;
  10. # TODO: add -n and -c options w/ zero checks)
  11. # line and column limits
  12. my $N = 10;
  13. my $C = 72;
  14. # current line and column counters
  15. my $n = 0;
  16. my $c = 0;
  17. # read all lines from STDIN
  18. while (<STDIN>)
  19. {
  20. # echo line to output
  21. print STDOUT $_;
  22. # echo line to console if it is important
  23. if (/(Warning|Error)/) {
  24. print STDERR "\n" if $c;
  25. print STDERR $_;
  26. $c = 0;
  27. }
  28. # only display progress every Nth step
  29. next if ++$n % $N;
  30. print STDERR ".";
  31. # wrap at column C to provide fixed-width rows of dots
  32. print STDERR "\n" unless ++$c % $C;
  33. }
  34. print STDERR "\n" if $c;