From e3da4842d2eb6d4c851ac008d5220bbddd87ad08 Mon Sep 17 00:00:00 2001 From: Neil Moore Date: Wed, 27 Jun 2012 01:28:59 -0500 Subject: Add log viewing apparatus to git. --- dat/log/.htaccess | 11 ++++++ dat/log/.logview.shtml | 88 ++++++++++++++++++++++++++++++++++++++++++++ dat/log/crawl-dev.log.concat | 62 +++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 dat/log/.htaccess create mode 100644 dat/log/.logview.shtml create mode 100755 dat/log/crawl-dev.log.concat diff --git a/dat/log/.htaccess b/dat/log/.htaccess new file mode 100644 index 0000000..9370bc3 --- /dev/null +++ b/dat/log/.htaccess @@ -0,0 +1,11 @@ +IndexOptions FancyIndexing NameWidth=30 SuppressHTMLPreamble +IndexOrderDefault Descending Name +IndexIgnore .* +IndexIgnore crawl-dev.log.concat +AddType text/plain .log +AddType text/html .shtml +AddOutputFilter INCLUDES .shtml +AddHandler cgi-script .concat +AddType text/plain .concat +HeaderName .logview.shtml +AddDescription "View log" * diff --git a/dat/log/.logview.shtml b/dat/log/.logview.shtml new file mode 100644 index 0000000..7d37f4a --- /dev/null +++ b/dat/log/.logview.shtml @@ -0,0 +1,88 @@ + + + + + +
+ + + +
+
+ + + + + + +
+
+ + + diff --git a/dat/log/crawl-dev.log.concat b/dat/log/crawl-dev.log.concat new file mode 100755 index 0000000..f42ba51 --- /dev/null +++ b/dat/log/crawl-dev.log.concat @@ -0,0 +1,62 @@ +#! /usr/bin/perl -w + +use CGI; +use IO::File; +use strict; + +my $q = new CGI; + +my $search = $q->param("s"); +my $wantre = $q->param("re"); +my $case = $q->param("cs") ? "" : "i"; +my @dlhead = (); + +$q->param("download") and @dlhead = ( + -Content_disposition => "attachment; filename = crawl-dev-search.log" +); + +print $q->header({ + -type => 'text/plain', -encoding => 'UTF-8', @dlhead +}); + +chdir "/home/szorg/public_html/crawl-dev"; + +# Test the regexp and show any error to the user. +$wantre and eval { + "" =~ /$search/; +}; +if ($@) { + print "$@\nSearch aborted."; + exit(0); +} + +my $matching_files=0; +FILE: for my $logf (<*.log>) { + my $f = new IO::File $logf, "<:encoding(UTF-8)"; + unless (defined $f) { + print "skipping $logf: $!\n"; + next FILE; + } + + my $matches = ""; + my $matchct = 0; + while (<$f>) { + chomp; + if (!defined($search) or $search eq "" + or ($wantre and /(?$case:$search)/) + or (!$wantre and /(?$case:\Q$search\E)/)) + { + $matches .= "$_\n"; + ++$matchct; + } + } + $f->close(); + + if ($matches) { + print "\n" if $matching_files++; + my $pl = $matchct == 1 ? "" : "es"; + print "$matchct match$pl in $logf:\n$matches"; + } +} + +print "No results found.\n" unless $matching_files; -- cgit v1.2.3-54-g00ecf