diff options
author | Neil Moore <neil@s-z.org> | 2012-06-27 01:28:59 -0500 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2012-06-27 01:28:59 -0500 |
commit | e3da4842d2eb6d4c851ac008d5220bbddd87ad08 (patch) | |
tree | 59b3629cb828e49390806943d509943cc64b55d1 /dat | |
parent | 2c6c3045675cecc82d33e73adf2066278a1a787c (diff) | |
download | crawlbot-e3da4842d2eb6d4c851ac008d5220bbddd87ad08.tar.gz crawlbot-e3da4842d2eb6d4c851ac008d5220bbddd87ad08.zip |
Add log viewing apparatus to git.
Diffstat (limited to 'dat')
-rw-r--r-- | dat/log/.htaccess | 11 | ||||
-rw-r--r-- | dat/log/.logview.shtml | 88 | ||||
-rwxr-xr-x | dat/log/crawl-dev.log.concat | 62 |
3 files changed, 161 insertions, 0 deletions
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 "<a href='#' onclick='wensley(this.previousSibling.previousSibling.attributes[\"href\"].value)'>View log</a>" * 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 @@ +<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"></script> +<script type="text/javascript"> +wensleysubmit = function() { + logurl = '%23%23crawl-dev-' + $('input#date').val() + '.log'; + wensley(logurl, {}); +} +wensleysearch = function() { + wensley('crawl-dev.log.concat', { + s: $('input#s').val(), + re: $('input#re:checked').val(), + cs: $('input#cs:checked').val(), + }); +} +wensleyclear = function() { + $('div#stuff').html(''); +} +wensley = function(logurl, args) { + $.get(logurl, args, function(data) { + data = data.replace(/&/g, '&'); + data = data.replace(/</g, '<'); + data = data.replace(/>/g, '>'); + + // Ugh: try to handle colour and bold tags. + data = data.replace(/\cC(?:0(\d)|([1-9]\d?))(?:,(?:0(\d)|([1-9]\d?)))?([^\cC\cO\n]*\cO?)/g, '<span class="fg$1$2 bg$3$4">$5</span>'); + data = data.replace(/\cB([^\cB\cO\n]*)\cO?/g, '<b>$1</b>'); + data = data.replace(/\cO/g, ''); + + data = data.replace(/\n/g, "<br>"); + $('div#stuff').html('<h2>Wensley is so awesome</h2><a href="#files">Jump to list of logs</a> | <a href="#" onclick="wensleyclear()">Close log</a><div class="irc">' + data + '</div>'); + }); +} +</script> +<style type="text/css"> + .irc { font-family: monospace; } + .fg0 { color: white; } + .fg1 { color: black; } + .fg2 { color: #4040ff; } + .fg3 { color: green; } + .fg4 { color: red; } + .fg5 { color: #ff4040; } + .fg6 { color: purple; } + .fg7 { color: #606000; } + .fg8 { color: #a0a000; } + .fg9 { color: #40ff40; } + .fg10 { color: teal; } + .fg11 { color: #00ffff; } + .fg12 { color: #8080ff; } + .fg13 { color: #ff00ff; } + .fg14 { color: #404040; } + .fg15 { color: #808080; } + .fg16 { color: black; } + .bg0 { background: white; } + .bg1 { background: black; } + .bg2 { background: #4040ff; } + .bg3 { background: green; } + .bg4 { background: red; } + .bg5 { background: #ff4040; } + .bg6 { background: purple; } + .bg7 { background: #606000; } + .bg8 { background: #a0a000; } + .bg9 { background: #40ff40; } + .bg10 { background: teal; } + .bg11 { background: #00ffff; } + .bg12 { background: #8080ff; } + .bg13 { background: #ff00ff; } + .bg14 { background: #404040; } + .bg15 { background: #808080; } + .bg16 { background: black; } +</style> +</head> +<body> +<form onsubmit="wensleysubmit();return false;"> + <label for="date">Enter a date in YYYYMMDD format:</label> + <input type="text" id="date" name="date"> + <input type="submit" id="submit" name="submit" value="Get log"> +</form> +<form method="get" action="crawl-dev.log.concat"> + <label for="s">Search for</label> <input type="text" name="s" id="s"> + <input type="checkbox" id="re" name="re"><label for="re">regex</label> + <input type="checkbox" id="cs" name="cs"><label for="cs">case-sensitive</label> + <input type="hidden" id="download" name="download" value="1"> + <input onclick="wensleysearch();return false;" type="submit" name="view" id="view" value="Search"> + <input type="submit" name="search" id="search" value="Download results"> +</form> +<div id="stuff"></div> +<a name="files"></a> +</body> + 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; |