--- loncom/metadata_database/parse_activity_log.pl 2005/09/20 17:49:51 1.19 +++ loncom/metadata_database/parse_activity_log.pl 2006/03/30 05:29:01 1.22 @@ -2,7 +2,7 @@ # # The LearningOnline Network # -# $Id: parse_activity_log.pl,v 1.19 2005/09/20 17:49:51 matthew Exp $ +# $Id: parse_activity_log.pl,v 1.22 2006/03/30 05:29:01 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -48,7 +48,9 @@ # parameter is not set $logthis is set to ¬hing, which does what you # would expect. # - +BEGIN { + eval "use Apache2::compat();"; +}; use strict; use DBI; use lib '/home/httpd/lib/perl/Apache'; @@ -184,7 +186,7 @@ if (! defined($xmlfile)) { if (!flock(LOCKFILE,LOCK_EX|LOCK_NB)) { warn("Unable to lock $lockfilename. Aborting".$/); # don't call clean_up_and_exit another instance is running and - # we don't want to 'cleanup' there files + # we don't want to 'cleanup' their files exit 6; } @@ -492,15 +494,10 @@ sub process_courselog { if (length($chunk) > 20000) { # avoid putting too much data into the database # (usually an uploaded file or something similar) - $chunk = &escape($chunk); - if (! open(CHUNKFILE,">>$chunk_filename") || - ! print CHUNKFILE $timestamp.':'.$host.':'.$chunk.$/) { - # abort - close(CHUNKFILE); + if (! &savechunk(\$chunk,$timestamp,$host)) { close(IN); return undef; } - close(CHUNKFILE); next; } my $warningflag = ''; @@ -519,8 +516,12 @@ sub process_courselog { if ($action !~ /^(LOGIN|VIEW|POST|CSTORE|STORE)$/) { $warningflag .= 'action'; print $error_fh 'full log entry:'.$log.$/; - print $error_fh 'error on chunk:'.$chunk.$/; - $logthis->('(action) Unable to parse '.$/.$chunk.$/. + print $error_fh 'error on chunk (saving)'.$/; + if (! &savechunk(\$chunk,$timestamp,$host)) { + close(IN); + return undef; + } + $logthis->('(action) Unable to parse chunk'.$/. 'got '. 'time = '.$time.$/. 'res = '.$res.$/. @@ -557,6 +558,20 @@ sub process_courselog { } close IN; return $linecount; + ## + ## + sub savechunk { + my ($chunkref,$timestamp,$host) = @_; + my $chunk = &escape(${$chunkref}); + if (! open(CHUNKFILE,">>$chunk_filename") || + ! print CHUNKFILE $timestamp.':'.$host.':'.$chunk.$/) { + # abort + close(CHUNKFILE); + return 0; + } + close(CHUNKFILE); + return 1; + } }