[Cpan-forum-commit] rev 178 - in trunk: . lib/CPAN

svn at pti.co.il svn at pti.co.il
Sat Aug 26 19:47:57 IDT 2006


Author: gabor
Date: 2006-08-26 19:47:57 +0300 (Sat, 26 Aug 2006)
New Revision: 178

Modified:
   trunk/
   trunk/Changes
   trunk/TODO
   trunk/lib/CPAN/Forum.pm
Log:
mprove logging



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:11022
   + 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:11023

Modified: trunk/Changes
===================================================================
--- trunk/Changes	2006-08-26 16:47:52 UTC (rev 177)
+++ trunk/Changes	2006-08-26 16:47:57 UTC (rev 178)
@@ -1,6 +1,10 @@
 
 v0.12 
 
+  Logging: add client IP to logger to enable filtering log messages based on that 
+
+  Clean up STDERR, move (some) voluntary warnings to logger
+
   Include link to AnnoCPAN, rearrange links
 
   Used on http://www.cpanforum.com/ but not released as a distribution
@@ -15,8 +19,8 @@
   Let people monitor all current and future modules associated with a certain PAUSE ID.
   (both RSS and e-mail)
   A table called "subscription_PAUSE"
-	
 
+
   Let people subscribe to all messages or all thread starters or all followups.
   Add a table called "subscription_all"
  

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2006-08-26 16:47:52 UTC (rev 177)
+++ trunk/TODO	2006-08-26 16:47:57 UTC (rev 178)
@@ -3,7 +3,6 @@
 
 
 
-
   Cleanup the schema. Currently the schema/schema.sql is not the same as the
   schema used in the live application.
 
@@ -24,8 +23,7 @@
    application fails.
 
 
-  Loggin: add client IP to logger and/or enable logging based on a single
-          client IP address
+  Logging: enable logging based on a single client IP address
   
   Clean up STDERR, move voluntary warnings to logger
 

Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm	2006-08-26 16:47:52 UTC (rev 177)
+++ trunk/lib/CPAN/Forum.pm	2006-08-26 16:47:57 UTC (rev 178)
@@ -420,6 +420,7 @@
             filename          => $log,
             min_level         => $log_level,
             mode              => 'append',
+            callbacks         => sub { $self->_logger(@_)},
             close_after_write => 1,
         },
         ],
@@ -450,6 +451,17 @@
     );
 }
 
+sub _logger {
+    my ($self, %h) = @_;
+    return sprintf "[%s] - %s - [%s] [%s] %s\n",
+            scalar(localtime), 
+            $h{level}, 
+            ($ENV{REMOTE_ADDR} || ''),
+            ($ENV{HTTP_REFERER} || ''),
+            $h{message};
+            # keys of the hash: level, message, name
+}
+
 sub _set_log_level {
     my ($self) = @_;
 
@@ -462,7 +474,7 @@
             warn "Invalid log level '$str'\n";
         }
     }
-    return 'critical'; 
+    return 'warning'; 
 }
 
 
@@ -716,9 +728,7 @@
 sub internal_error {
     my ($self, $msg, $tag) = @_;
     if ($msg) {
-        $msg .= " REFERER: $ENV{HTTP_REFERER}" if $ENV{HTTP_REFERER};
-        warn $msg;
-        $self->log->debug($msg);
+        $self->log->warning($msg);
     }
     my $t = $self->load_tmpl("internal_error.tmpl");
     $t->param($tag => 1) if $tag;



More information about the Cpan-forum-commit mailing list