We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
Tags:
create new tag
, view all tags

Question

logFilename from Twiki.cfg has 22 Nov 2008 expanded into the current year/month. warningFilename and debugFilename do not.

I came across this as our admin configured it that way be accident. It seems like a simple change to the writeWarning and writeDebug functions in TWiki.pm.

Is it not a bad idea to?

Is there a good reason not to do this?

Here's a diff to make life easy

Category: TWikiPatches

Diff is against the the CairoRelease? aka TWikiRelease01Sep2004? ?

--- twiki/lib/TWiki.pm   2004-08-30 08:46:11.000000000 +0200
+++ new-twiki/lib/TWiki.pm   2004-09-07 16:08:42.000000000 +0200
@@ -242,25 +242,29 @@
 
 sub writeWarning {
     my( $text ) = @_;
     if( $warningFilename ) {
         my ( $sec, $min, $hour, $mday, $mon, $year ) = localtime( time() );
    my( $tmon) = $isoMonth[$mon];
         $year = sprintf( "%.4u", $year + 1900 );
         my $time = sprintf( "%.2u ${tmon} %.2u - %.2u:%.2u",
             $mday, $year, $hour, $min );
 
-        if( open( FILE, ">>$warningFilename" ) ) {
+        my $yearmonth = sprintf( "%.4u%.2u", $year, $mon+1 );
+        my $filename = $TWiki::warningFilename;
+        $filename =~ s/%DATE%/$yearmonth/go;
+
+        if( open( FILE, ">>$filename" ) ) {
             print FILE "$time $text\n";
             close( FILE );
         } else {
-            print STDERR "Couldn't write \"$text\" to $warningFilename: $!\n";
+            print STDERR "Couldn't write \"$text\" to $filename: $!\n";
         }
     }
 }
 
 =pod
 
 ---++ writeDebug( $text )
 
 Prints date, time, and contents of $text to $debugFilename, typically
 'debug.txt'.  Use for debugging messages.
@@ -268,25 +272,29 @@
 =cut
 
 sub writeDebug {
     my( $text ) = @_;
     
     my ( $sec, $min, $hour, $mday, $mon, $year ) = localtime( time() );
     my( $tmon) = $isoMonth[$mon];
     $year = sprintf( "%.4u", $year + 1900 );
     my $time = sprintf( "%.2u ${tmon} %.2u - %.2u:%.2u", $mday, $year, $hour, $min );
 
-    if( open( FILE, ">>$debugFilename" ) ) {
+    my $yearmonth = sprintf( "%.4u%.2u", $year, $mon+1 );
+    my $filename = $TWiki::debugFilename;
+    $filename =~ s/%DATE%/$yearmonth/go;
+
+    if( open( FILE, ">>$filename" ) ) {
          print FILE "$time $text\n";
          close( FILE );
     } else {
-         print STDERR "Couldn't write \"$text\" to $debugFilename: $!\n";
+         print STDERR "Couldn't write \"$text\" to $filename: $!\n";
     }
 }
 
 =pod
 
 ---++ writeDebugTimes( $text )
 
 Dumps user and system time spent, with deltas from last call, followed
 by contents of $text, to debug log using writeDebug above.  Use for
 performance monitoring/debugging.

Environment

TWiki version: TWikiRelease01Feb2003
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: linux
Web server: apache
Perl version: 5.8.0
Client OS: linux
Web Browser: firefox 0.8

-- KevinBaker - 07 Sep 2004

Answer

I pasted this to SupportDATEInAllLogFilenames, as a patch proposal, as I think it's a really good idea - though I would personally code it so there was a generic way of generating date-based filenames.

-- CrawfordCurrie - 10 Sep 2004

Topic revision: r3 - 10 Sep 2004 - 07:36:11 - CrawfordCurrie
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback