Hi Sven,

Sorry about the previous patches, readability wasn't something that I
considered, I admit it.

Here's the unified format patch, hope it's OK now.


Regards,
Mihai

On 10/16/2011 08:59 PM, Sven Hoexter wrote:
> severity 644896 normal
> tags 644896 - patch
> thanks
>
> On Wed, Oct 12, 2011 at 12:36:47PM +0300, Mihai Stan wrote:
>
> Hi,
>
> your patch doesn't apply here against the pflogsumm.pl as shiped in the
> source package, which should be unmodified. When you rediff please provide
> it in the unified format (-u). Honestly, the default diff format is just 
> pain to read.
>
> Sven

diff -u pflogsumm-1.1.3-orig//pflogsumm.pl pflogsumm-1.1.3/pflogsumm.pl
--- pflogsumm-1.1.3-orig//pflogsumm.pl  2010-03-20 20:00:42.000000000 +0000
+++ pflogsumm-1.1.3/pflogsumm.pl        2011-10-11 15:25:31.000000000 +0000
@@ -451,7 +451,7 @@
 
 my (
     $cmd, $qid, $addr, $size, $relay, $status, $delay,
-    $dateStr,
+    $dateStr, $dateStrRFC3339,
     %panics, %fatals, %warnings, %masterMsgs,
     %msgSizes,
     %deferred, %bounced,
@@ -612,13 +612,14 @@
 }
 
 $dateStr = get_datestr($opts{'d'}) if(defined($opts{'d'}));
+$dateStrRFC3339 = get_datestr($opts{'d'}, 'rfc3339')  if(defined($opts{'d'}));
 
 # debugging
 #open(UNPROCD, "> unprocessed") ||
 #    die "couldn't open \"unprocessed\": $!\n";
 
 while(<>) {
-    next if(defined($dateStr) && ! /^$dateStr/o);
+    next if((defined($dateStr) && ! /^$dateStr/o) && (defined($dateStrRFC3339) 
&& ! /^$dateStrRFC3339/o));
     s/: \[ID \d+ [^\]]+\] /: /o;       # lose "[ID nnnnnn some.thing]" stuff
     my $logRmdr;
 
@@ -631,7 +632,7 @@
     } else {
        # RFC 3339 timestamp format?
        next unless((($msgYr, $msgMon, $msgDay, $msgHr, $msgMin, $msgSec, 
$logRmdr) =
-           
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:[\+\-](?:\d{2}):(?:\d{2})|Z)
 \S+ (.+)$/o) == 10);
+           
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:[\+\-](?:\d{2}):(?:\d{2})|Z)
 \S+ (.+)$/o) == 7);
        # RFC 3339 months start at "1", we index from 0
        --$msgMon;
     }
@@ -1500,6 +1501,7 @@
 # return a date string to match in log
 sub get_datestr {
     my $dateOpt = $_[0];
+  my $format = $_[1];
 
     my $time = time();
 
@@ -1509,9 +1511,13 @@
     } elsif($dateOpt ne "today") {
        die "$usageMsg\n";
     }
-    my ($t_mday, $t_mon) = (localtime($time))[3,4];
+    my ($t_mday, $t_mon, $t_year) = (localtime($time))[3,4,5];
 
-    return sprintf("%s %2d", $monthNames[$t_mon], $t_mday);
+  if(defined($format) && $format eq 'rfc3339') {
+      return sprintf("%4d-%2d-%2d", $t_year+1900, $t_mon+1, $t_mday);
+  } else {
+      return sprintf("%s %2d", $monthNames[$t_mon], $t_mday);
+  }
 }
 
 # if there's a real domain: uses that.  Otherwise uses the IP addr.

Reply via email to