From: Don Armstrong Date: Wed, 5 Apr 2006 00:51:29 +0000 (+0000) Subject: add joeyh's logview X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=7b26c9447e6e6b7ef084d85e53bbfbd5bca141f9;p=bin.git add joeyh's logview --- diff --git a/logview b/logview new file mode 100755 index 0000000..d88e6dc --- /dev/null +++ b/logview @@ -0,0 +1,29 @@ +#!/usr/bin/perl +# Log viewer program. Pass it parameters of the logs to view, or it will +# automatically view some. + +$|=1; + +$logdir='/var/log'; +@logfiles=@ARGV; + +# If I am root, look at all logs, otherwise only those that are +# world-readable. +my $perm=''; +$perm='-perm +6' if $? != 0; +if (! @logfiles) { + @logfiles=split /\n/, `find $logdir -type f -regex '.*.log' ! -name faillog ! -name lastlog $perm`; + push @logfiles, "$logdir/mail.err", "$logdir/mail.warn"; +} + +if (-e $ENV{HOME}."/.xsession-errors") { + push @logfiles, $ENV{HOME}."/.xsession-errors"; +} + +# Tail without wasting the last line of the screen. +open(TAIL, "tail -q --follow=name --retry -n 2 @logfiles|"); +while () { + print "\n"; + chomp; + print $_; +}