]> git.donarmstrong.com Git - bin.git/commitdiff
add joeyh's logview
authorDon Armstrong <don@donarmstrong.com>
Wed, 5 Apr 2006 00:51:29 +0000 (00:51 +0000)
committerDon Armstrong <don@donarmstrong.com>
Wed, 5 Apr 2006 00:51:29 +0000 (00:51 +0000)
logview [new file with mode: 0755]

diff --git a/logview b/logview
new file mode 100755 (executable)
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 (<TAIL>) {
+       print "\n";
+       chomp;
+       print $_;
+}