2 ###APPNAME: apt-log-show
3 ###APPAUTHOR: xiaoranzzz
4 ###APPDATE: Wed Apr 2 00:42:39 2008
13 print STDERR
("[sudo:]",join(" ",@_),"\n");
15 return (system(@_)==0);
18 return (system("sudo",@_)==0);
22 my $logfile=shift || "/var/log/apt/term.log";
24 if($logfile && -f
$logfile) {
25 if(!open $log_h,"<",$logfile) {
26 print STDERR
"Open $logfile for reading error:$!\n";
27 print STDERR
"Trying sudo...\n";
28 open $log_h,"-|","sudo cat '$logfile'" or die("$!\n");
36 my $filters=qr/^\s*(:?Setting up|Removing|dpkg)\b/;
40 next unless(/^Log started:\s+(.*)\s+(.*)\s*$/);
42 # $logs{$date}=() unless(exists $logs{$date});
48 push(@
{$logs{$date}},$_) if(m/$filters/);
54 #use Term::ANSIColor qw/:constants/;
55 use constant
{RESET
=>"",GREEN
=>"",YELLOW
=>""};
60 foreach my $title (sort keys %logs) {
62 my @items = @
{$logs{$title}};