# Tommy Fad
# National Instruments
# 6/19/2003
# Purpose: Quick hack to parse the p4log file...
# Usage: processlog.pl <p4logfile>
use Strict;
use Time::Local;
my @line;
my @inner;
my @date;
my @time;
my $secondsBegin;
my $secondsEnd;
my %processes;
my $data;
my $j=0;
my $i=0;
# Specify where the Perforce log file is
open LOGFILE, $ARGV[0] || die "Oh no: $!\n";
while(<LOGFILE>){
if(/\t\b\d\d\d\d/){
$data = $_;
@line = split(/ /,$data);
if(length($processes{$line[3]})>0){
if($line[4] =~ "completed"){
@inner = split(/ /,$processes{$line[3]});
@date = split(/\//,$inner[0]);
@time = split(/:/,$inner[1]);
$secondsBegin = timelocal($time[2],$time[1],$time[0],$date[2],($date[1] - 1),$date[0]);
@date = split(/\//,$line[0]);
@time = split(/:/,$line[1]);
$secondsEnd = timelocal($time[2],$time[1],$time[0],$date[2],($date[1] -1),$date[0]);
if($inner[4] =~ "completed"){
print "DUPLICATE: $inner[3]\n";
$processes{$line[3]} = "";
}
else{
print "User: " . $inner[4] . "\t" . "Process ID: " . $inner[3] . "\t" . "Time Started: " . $inner[1] . "\t" . "Date Started: " . $inner[0] . "\n";
print "User: " . $inner[4] . "\t" . "Process ID: " . $line[3] . "\t" . "Time Finished: " . $line[1] . "\t" . "Date Finished: " . $line[0] . "\n";
print "Seconds Elapsed: " . ($secondsEnd - $secondsBegin) . "\n";
print "Commands Run...\n";
$_ = $processes{$line[3]};
/\'/;
print "'" . $' . "\n";
$processes{$line[3]} = "";
}
}
else{
$_ = $data;
/\'/;
$processes{$line[3]} = $processes{$line[3]} . "'" . $' . "\n";
}
}
else{
$processes{$line[3]} = $data;
}
}
}
foreach $key (keys (%processes)){
if(length($processes{$key})>0){
print "\n$key is still running\n";
print "$processes{$key}\n";
}
}
close LOGFILE;
# |
Change |
User |
Description |
Committed |
|
#1
|
3338 |
Tommy Fad |
Quick hack to parse the p4 log file...in case it is useful to anyone else. |
|
|