Przeglądaj źródła

* When a logfile had no matching lines according to the format, pisg
outputted that no lines were found in the logfile. This was confusing
because files in the wrong format usually contained lines. Now be more
verbose.

Morten Brix Pedersen 23 lat temu
rodzic
commit
55463f1c2c

+ 4 - 0
docs/Changelog

@@ -17,6 +17,10 @@ pisg (x.xx)
      ignored words if this is set.  Will output a blank line after trying 20
      random quotes if all 20 random quotes were ignored.
    * Add support for HydraIRC logfiles (thanks, David Lynch)
+   * When a logfile had no matching lines according to the format, pisg
+     outputted that no lines were found in the logfile. This was confusing
+     because files in the wrong format usually contained lines. Now be more
+     verbose.
 
 pisg (0.46) - Tue Feb, 11th 2003
    * Fix serious bug which caused garbled output i "Latest topics" and other

+ 3 - 2
docs/dev/API

@@ -63,8 +63,9 @@ topics        array          Each array element is a hash with the
                                min   - The minute in which the change took
                                        place.
 days          scalar         Number of days the reporting period spanned.
-totallines    scalar         Total number of lines (normal, action, and
-                             third) seen in channel.
+totallines    scalar         Total number of lines seen in file(s).
+parsedlines   scalar         Total number of parseable lines (normal,
+                             action, and third) seen in channel.
 processtime   hash           A hash containing 'hours', 'mins' and 'secs',
                              describing the time elapsed while processing
                              this channel.

+ 4 - 3
modules/Pisg.pm

@@ -507,11 +507,12 @@ _END
         }
 
         # Create our HTML page if the logfile has any data.
-        if (defined $stats and $stats->{totallines} > 0) {
+        if (defined $stats and $stats->{parsedlines} > 0) {
             $generator->create_html();
-        } elsif ($stats->{totallines} == 0) {
-            print STDERR "No lines found in logfile.. skipping.\n";
+        } elsif ($stats->{parsedlines} == 0) {
+            print STDERR "No parseable lines found in logfile ($stats->{totallines} total lines). Skipping.\nYou might be using the wrong format.\n";
         }
+
         restore_aliases();
 
         $self->{cfg}->{chan_done}{$self->{cfg}->{channel}} = 1;

+ 2 - 2
modules/Pisg/HTMLGenerator.pm

@@ -130,7 +130,7 @@ sub create_html
         _html("</table>"); # Needed for sections
     }
 
-    my %hash = ( lines => $self->{stats}->{totallines} );
+    my %hash = ( lines => $self->{stats}->{parsedlines} );
     _html($self->_template_text('totallines', %hash) . "<br /><br />");
 
     $self->_pagefooter()
@@ -318,7 +318,7 @@ sub _activetimes
     for my $hour (sort keys %{ $self->{stats}->{times} }) {
 
         my $size = ($self->{stats}->{times}{$hour} / $highest_value) * 100;
-        my $percent = ($self->{stats}->{times}{$hour} / $self->{stats}->{totallines}) * 100;
+        my $percent = ($self->{stats}->{times}{$hour} / $self->{stats}->{parsedlines}) * 100;
         $percent =~ s/(\.\d)\d+/$1/;
 
         if ($size < 1 && $size != 0) {

+ 6 - 3
modules/Pisg/Parser/Logfile.pm

@@ -57,6 +57,7 @@ sub analyze
 
         # Just initialize these to 0
         $stats{days} = 0;
+        $stats{parsedlines} = 0;
         $stats{totallines} = 0;
 
         if ($self->{cfg}->{logdir}) {
@@ -253,7 +254,7 @@ sub _parse_file
                 $state->{oldtime} = $hour;
 
                 if (!is_ignored($nick)) {
-                    $stats->{totallines}++;
+                    $stats->{parsedlines}++;
 
                     # Timestamp collecting
                     $stats->{times}{$hour}++;
@@ -335,7 +336,7 @@ sub _parse_file
 
         # Match action lines.
         elsif ($hashref = $self->{parser}->actionline($line, $.)) {
-            $stats->{totallines}++;
+            $stats->{parsedlines}++;
 
             my ($hour, $nick, $saying);
 
@@ -384,7 +385,7 @@ sub _parse_file
 
         # Match *** lines.
         elsif (($hashref = $self->{parser}->thirdline($line, $.)) and $hashref->{nick}) {
-            $stats->{totallines}++;
+            $stats->{parsedlines}++;
 
             my ($hour, $min, $nick, $kicker, $newtopic, $newmode, $newjoin);
             my ($newnick);
@@ -435,6 +436,8 @@ sub _parse_file
         }
     }
 
+    $stats->{totallines} = $.;
+
     close(LOGFILE);
 
     print "Finished analyzing log, $stats->{days} days total.\n"