فهرست منبع

* Added NFiles option, which can be used for LogDirs to only parse the last
N files (thanks, Christoph Berg)
* Added OutputTag option, which enables users to have variable output names
(see documentation). (thanks, Christoph Berg)

Morten Brix Pedersen 23 سال پیش
والد
کامیت
1e6fc86841
7فایلهای تغییر یافته به همراه119 افزوده شده و 7 حذف شده
  1. 6 0
      docs/Changelog
  2. 3 1
      docs/Makefile
  3. 86 0
      docs/pisg-doc.sgml
  4. 3 1
      modules/Pisg.pm
  5. 5 3
      modules/Pisg/HTMLGenerator.pm
  6. 12 2
      modules/Pisg/Parser/Logfile.pm
  7. 4 0
      pisg

+ 6 - 0
docs/Changelog

@@ -1,3 +1,9 @@
+pisg (x.xx)
+   * Added NFiles option, which can be used for LogDirs to only parse the last
+     N files (thanks, Christoph Berg)
+   * Added OutputTag option, which enables users to have variable output names
+     (see documentation). (thanks, Christoph Berg)
+
 pisg (0.49) - Sun Sep, 14th 2003
    * Make the HTML output XHTML compliant again (thanks, Stian Jordet)
    * Add a bullet conversion character to Common.pm (thanks, Stian Jordet)

+ 3 - 1
docs/Makefile

@@ -1,5 +1,7 @@
+DOCBOOK_UTILS=/usr/share/sgml/docbook/utils-0.6.13
+
 all:
-	jade -i html -t sgml -V nochunks -d /usr/share/sgml/docbook/utils-0.6.13/docbook-utils.dsl\#html pisg-doc.sgml | w3m -dump -T text/html > pisg-tmp.txt
+	jade -i html -t sgml -V nochunks -d $(DOCBOOK_UTILS)/docbook-utils.dsl\#html pisg-doc.sgml | w3m -dump -T text/html > pisg-tmp.txt
 	cat pisg-tmp.txt | ./modifytxt.pl > pisg-doc.txt
 	docbook2html pisg-doc.sgml -o html
 

+ 86 - 0
docs/pisg-doc.sgml

@@ -506,6 +506,56 @@
     </refsect1>
     </refentry>
 
+    <!-- *** OUTPUTTAG *** -->
+    <refentry id="OutputTag">
+
+    <refmeta> <refentrytitle>OutputTag</refentrytitle> </refmeta>
+
+    <refnamediv>
+    <refname>OutputTag</refname>
+    <refpurpose>tag to insert into OutputFile</refpurpose>
+    </refnamediv>
+
+    <refsynopsisdiv><programlisting>
+      <![CDATA[
+        <channel="#channel">
+         LogDir = "logs/"
+         Format = "eggdrop"
+         OutputFile = "mychan%t.html"
+         OutputTag = "-week"
+        </channel>
+
+        <set OutputTag="-week">
+      ]]>
+    </programlisting></refsynopsisdiv>
+
+    <refsect1>
+    <title>Description</title>
+    <para>
+    <command>OutputTag</command>specifies a string that will replace
+    occurrences of "%t" in <command>OutputFile</command>. This option is most
+    useful when used as a command line switch (-t) to pisg in conjunction with
+    <command>NFiles</command> (-nf). Example:
+
+    <programlisting>
+      <![CDATA[
+      $ pisg -co pisg.conf
+      $ pisg -co pisg.conf -nf 8 -t -week
+      ]]>
+    </programlisting>
+
+    Leaving out the <command>OutputTag</command> settings from the above
+    pisg.conf snippet, this writes both the full statistics (mychan.html) and
+    statistics for the last week (mychan-week.html) using the same pisg config
+    file. (Assuming that there are separate logfiles for each day.)
+    </para>
+    </refsect1>
+    <refsect1>
+    <title>Default</title>
+    <para> unset </para>
+    </refsect1>
+    </refentry>
+
     <!-- *** LOGFILE *** -->
     <refentry id="Logfile">
 
@@ -576,6 +626,42 @@
     </refsect1>
     </refentry>
 
+    <!-- *** NFILES *** -->
+    <refentry id="NFiles">
+
+    <refmeta> <refentrytitle>NFiles</refentrytitle> </refmeta>
+
+    <refnamediv>
+    <refname>NFiles</refname>
+    <refpurpose>parse only the last files in <command>LogDir</command></refpurpose>
+    </refnamediv>
+
+    <refsynopsisdiv><programlisting>
+      <![CDATA[
+        <channel="#channel">
+         LogDir="/home/foo/eggdrop/logs/"
+         NFiles="8"
+         Format="eggdrop"
+        </channel>
+
+        <set NFiles="8">
+      ]]>
+    </programlisting></refsynopsisdiv>
+
+    <refsect1>
+    <title>Description</title>
+    <para>
+    When <command>NFiles</command> is set to a positive integer, pisg will
+    process at most that much files from <command>LogDir</command>. Useful to
+    create statistics that cover the last week or month.
+    </para>
+    </refsect1>
+    <refsect1>
+    <title>Default</title>
+    <para> 0 (process all files) </para>
+    </refsect1>
+    </refentry>
+
     <!-- *** MAINTAINER *** -->
     <refentry id="Maintainer">
 

+ 3 - 1
modules/Pisg.pm

@@ -96,6 +96,7 @@ sub get_default_config_settings
         format => 'mIRC',
         network => 'SomeIRCNet',
         outputfile => 'index.html',
+        outputtag => '',
         maintainer => 'MAINTAINER',
         pagehead => 'none',
         pagefoot => 'none',
@@ -103,6 +104,7 @@ sub get_default_config_settings
         imagepath => '',
         defaultpic => '',
         logdir => '',
+        nfiles => 0,
         lang => 'en',
         langfile => 'lang.txt',
         cssdir => 'layout/',
@@ -194,7 +196,7 @@ sub get_default_config_settings
 
         botnicks => '',            # Needed for DCpp format (non-irc)
 
-        version => "0.49",
+        version => "0.50-cvs",
     };
 
     # Backwards compatibility with old option names:

+ 5 - 3
modules/Pisg/HTMLGenerator.pm

@@ -37,11 +37,13 @@ sub create_html
 
     $self->_topactive();
 
-    print "Now generating HTML($self->{cfg}->{outputfile})...\n"
+    my $fname = $self->{cfg}->{outputfile};
+    $fname =~ s/\%t/$self->{cfg}->{outputtag}/g;
+    print "Now generating HTML($fname)...\n"
         unless ($self->{cfg}->{silent});
 
-    open (OUTPUT, "> $self->{cfg}->{outputfile}") or
-        die("$0: Unable to open outputfile($self->{cfg}->{outputfile}): $!\n");
+    open (OUTPUT, "> $fname") or
+        die("$0: Unable to open outputfile($fname): $!\n");
 
     if ($self->{cfg}->{showtime}) {
         $self->{cfg}->{tablewidth} += 40;

+ 12 - 2
modules/Pisg/Parser/Logfile.pm

@@ -108,8 +108,13 @@ sub _parse_dir
     # Add trailing slash when it's not there..
     $self->{cfg}->{logdir} =~ s/([^\/])$/$1\//;
 
-    print "Going into $self->{cfg}->{logdir} and parsing all files there...\n\n"
-        unless ($self->{cfg}->{silent});
+    unless ($self->{cfg}->{silent}) {
+        unless ($self->{cfg}->{nfiles} > 0) {
+            print "Going into $self->{cfg}->{logdir} and parsing all files there...\n\n"
+        } else {
+            print "Going into $self->{cfg}->{logdir} and parsing the last $self->{cfg}->{nfiles} file(s) there...\n\n"
+        }
+    }
     my @filesarray;
     opendir(LOGDIR, $self->{cfg}->{logdir}) or
     die("Can't opendir $self->{cfg}->{logdir}: $!");
@@ -194,6 +199,11 @@ sub _parse_dir
         @filesarray = sort {lc($a) cmp lc($b)} @filesarray;
     }
 
+    if($self->{cfg}->{nfiles} > 0) {
+        my $shift = @filesarray - $self->{cfg}->{nfiles};
+        splice(@filesarray, 0, $shift);
+    }
+
     foreach my $file (@filesarray) {
         $file = $self->{cfg}->{logdir} . $file;
         $self->_parse_file($stats, $lines, $file, \%state);

+ 4 - 0
pisg

@@ -86,10 +86,12 @@ Usage: pisg [-ch channel] [-l logfile] [-o outputfile] [-ma maintainer]
                          times to do multiple channels
 -l  --logfile=xxx      : Log file to parse
 -o  --outfile=xxx      : Name of HTML file to create
+-t  --tag=xxx          : Replace \%t in --outfile by xxx
 -ma --maintainer=xxx   : Channel/statistics maintainer
 -f  --format=xxx       : Logfile format [see FORMATS file]
 -n  --network=xxx      : IRC network for the channel
 -d  --dir=xxx          : Analyze all files in this dir. Ignores logfile
+-nf --nfiles=xxx       : Analyze the last xxx files if used with --dir
 -p  --prefix=xxx       : Analyse only files prefixed by xxx in dir
                          Only works with --dir
 -cf --cfg opt=value    : Specify configuration options, eg. -cf ShowWpl=1
@@ -114,7 +116,9 @@ END_USAGE
                    'network=s'    => \$cfg{network},
                    'maintainer=s' => \$cfg{maintainer},
                    'outfile=s'    => \$cfg{outputfile},
+                   'tag=s'        => \$cfg{outputtag},
                    'dir=s'        => \$cfg{logdir},
+                   'nfiles=i'     => \$cfg{nfiles},
                    'prefix=s'     => \$cfg{logprefix},
                    'moduledir=s'  => \$cfg{moduledir},
                    'configfile=s' => \$cfg{configfile},