version 1.16, 2005/09/19 18:31:57
|
version 1.19, 2005/09/20 17:49:51
|
Line 131 if ($log) {
|
Line 131 if ($log) {
|
print STDERR "$0: logging to $logfile".$/; |
print STDERR "$0: logging to $logfile".$/; |
if (! open(LOGFILE,">$logfile")) { |
if (! open(LOGFILE,">$logfile")) { |
warn("Unable to open $logfile for writing. Run aborted."); |
warn("Unable to open $logfile for writing. Run aborted."); |
&cleanup_and_exit(5); |
&clean_up_and_exit(5); |
} else { |
} else { |
$logthis = \&log_to_file; |
$logthis = \&log_to_file; |
} |
} |
Line 144 if ($log) {
|
Line 144 if ($log) {
|
my $sourcefilename; # activity log data |
my $sourcefilename; # activity log data |
my $newfilename; # $sourcefilename will be renamed to this |
my $newfilename; # $sourcefilename will be renamed to this |
my $error_filename; # Errors in parsing the activity log will be written here |
my $error_filename; # Errors in parsing the activity log will be written here |
|
my $chunk_filename; # where we save data we are not going to write to db |
if ($srcfile) { |
if ($srcfile) { |
$sourcefilename = $srcfile; |
$sourcefilename = $srcfile; |
} else { |
} else { |
Line 153 my $sql_filename = $sourcefilename;
|
Line 154 my $sql_filename = $sourcefilename;
|
$sql_filename =~ s|[^/]*$|activity.log.sql|; |
$sql_filename =~ s|[^/]*$|activity.log.sql|; |
my $gz_sql_filename = $sql_filename.'.gz'; |
my $gz_sql_filename = $sql_filename.'.gz'; |
# |
# |
|
$chunk_filename = $sourcefilename.".unprocessed_chunks"; |
|
# |
my $xml_filename = $sourcefilename; |
my $xml_filename = $sourcefilename; |
my $gz_xml_filename = $xml_filename.'.gz'; |
my $gz_xml_filename = $xml_filename.'.gz'; |
if (defined($xmlfile)) { |
if (defined($xmlfile)) { |
Line 180 if (! defined($xmlfile)) {
|
Line 183 if (! defined($xmlfile)) {
|
open(LOCKFILE,'>'.$lockfilename); |
open(LOCKFILE,'>'.$lockfilename); |
if (!flock(LOCKFILE,LOCK_EX|LOCK_NB)) { |
if (!flock(LOCKFILE,LOCK_EX|LOCK_NB)) { |
warn("Unable to lock $lockfilename. Aborting".$/); |
warn("Unable to lock $lockfilename. Aborting".$/); |
&clean_up_and_exit(6); |
# don't call clean_up_and_exit another instance is running and |
|
# we don't want to 'cleanup' there files |
|
exit 6; |
} |
} |
|
|
if (! -e $newfilename && -e $sourcefilename) { |
if (! -e $newfilename && -e $sourcefilename) { |
Line 484 sub process_courselog {
|
Line 489 sub process_courselog {
|
if (! defined($host)) { $host = 'unknown'; } |
if (! defined($host)) { $host = 'unknown'; } |
my $prevchunk = 'none'; |
my $prevchunk = 'none'; |
foreach my $chunk (split(/\&\&\&/,$log)) { |
foreach my $chunk (split(/\&\&\&/,$log)) { |
|
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); |
|
close(IN); |
|
return undef; |
|
} |
|
close(CHUNKFILE); |
|
next; |
|
} |
my $warningflag = ''; |
my $warningflag = ''; |
my ($time,$res,$uname,$udom,$action,@values)= split(/:/,$chunk); |
my ($time,$res,$uname,$udom,$action,@values)= split(/:/,$chunk); |
|
# |
if (! defined($res) || $res =~ /^\s*$/) { |
if (! defined($res) || $res =~ /^\s*$/) { |
$res = '/adm/roles'; |
$res = '/adm/roles'; |
$action = 'LOGIN'; |
$action = 'LOGIN'; |