Package: cronolog
Version: 1.6.2-5
Severity: minor

In order to use BTS as my memo:

Some more things where I'd like to improve cronosplit:

* --utime option

This modifies the mtime of the created logfiles to the timestamp of the
last access line. Used to make the converted files look more authentic :-)

Patch attached.

* manpage --print-invalid

The --print-invalid option is not explained in the manpage.

* manpage: advanced usage

Give an example of usage for a huge set of logfiles. Basically you'd
not want to process the logfiles in globbed order but something like


    for TYPE in access error ; do
        for i in `seq 52 -1 1` '' ; do
            if [ "$i" ] ; then
                i=".$i"
            fi
            LOGFILE=/var/log/apache2/$TYPE.log$i

            if [ ! -f "$LOGFILE" ] ; then
                continue
            fi

            nice cronosplit --print-invalid \
                --template=TEMPLATE "$LOGFILE"
        done
    done


* manpage: BUGS section

cronosplit can now process error logfiles but only those that have a
date at the beginning of the line.


Oh, and by the way:
* manpage of cronolog

The example should refer to the actual location of cronolog i.e.

- TransferLog "|/www/sbin/cronolog /www/logs/%Y/%m/%d/access.log"
+ TransferLog "|/usr/bin/cronolog /www/logs/%Y/%m/%d/access.log" 

Same for ErrorLog.

    Christoph

-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.16.16
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=UTF-8)

Versions of packages cronolog depends on:
ii  libc6                 2.3.2.ds1-22sarge3 GNU C Library: Shared libraries an
ii  perl [perl5]          5.8.4-8sarge4      Larry Wall's Practical Extraction 
--- cronosplit.LAST	2006-06-04 16:50:27.000000000 +0200
+++ cronosplit	2006-06-04 15:49:38.000000000 +0200
@@ -122,6 +122,7 @@
 my $template;
 my $debug;
 my $verbose;
+my $utime;
 my $PrintInvalids;
 my $print_help;
 my $print_version;
@@ -129,11 +130,13 @@
 
 my %OpenHandles = ();
 my @HandlesInUse = ();
+my %utimes = ();
 
 # Process options
 
 (GetOptions("template=s",	\$template,
 	    "print-invalid",	\$PrintInvalids,
+	    "utime",		\$utime,
 	    "debug",            \$debug,
 	    "verbose",          \$verbose,
 	    "help",             \$print_help,
@@ -176,6 +179,7 @@
 
   --template=TEMPLATE   output log-file template
   --print-invalid       print invalid log-file entries
+  --utime               update mtime of output files to last entry
   --help                print this help, then exit
   --version             print version number, then exit
 EOS
@@ -264,6 +268,17 @@
     close(INFILE);
 }
 
+# close any open files
+foreach my $oldkey (@HandlesInUse)
+{
+    $handle = $OpenHandles{$oldkey};
+     close $handle;
+    if ($utime)
+    {
+	my $mtime = $utimes{$oldkey};
+	utime $mtime, $mtime, $oldkey;
+    } 
+}
 
 # Get a file handle for a log file, closing the oldest handle if there
 # are too many handles open
@@ -279,6 +294,14 @@
     my(@time) = localtime($time_t);
     $file =~ s/(%[a-zA-Z%])/strftime($1, @time)/eg;
 
+    if ($utime)
+    {
+	if (!defined ($utimes{$file}) || $time_t > $utimes{$file})
+	{
+	    $utimes{$file} = $time_t;
+	}
+    }
+
     # See if we already have it open and ready to write
     
     return $handle if defined($handle = $OpenHandles{$file});
@@ -289,8 +312,13 @@
     {
         my ($oldkey) = shift @HandlesInUse;   # close the oldest
         $handle = $OpenHandles{$oldkey};
-        delete $OpenHandles{$oldkey};
         close $handle;
+	if ($utime)
+	{
+	    my $mtime = $utimes{$oldkey};
+	    utime $mtime, $mtime, $oldkey;
+	} 
+        delete $OpenHandles{$oldkey};
     }
 
     # Finally, try to open and remember a new handle for this pathkey

Reply via email to