Re: php service

"Stefan" <[email protected]>
Newsgroups gmane.comp.log.logwatch.devel
Message-ID <[email protected]>
Hello  
>  Sa Nov 16 2013 14:12:04 CET von "gulikoza"
><[email protected]>  Betreff: [Logwatch-devel] php service
>
>  Hello,
>
>PHP service does not find any logs on my Centos6 machine. There's a couple
>of problems:
>
>- it is only configured to search for php logfile group (httpd/php_log,
>apache2/php_error_log, ...) so the administrator needs to configure php to
>use the same logfiles, while http-error service will specifically ignore all
>PHP related errors in http-error log group ("skip PHP messages (have a
>separate script)")
>
>  

  This is a feature, not a bug. The administrator (or package maintainer) is
responsible to configure logwatch according to its setup.

  
>  - while both scripts have similar structure, php is using a different time
> format and skips all messages on my machine.
> 
>
>  

  Actually it's again the admin's (package maintainer's) responsibility to
use a proper time format. In this case it can not be achieved without
modifying the service script. I plan to fix that, by using ApplyStdDate with
an argument.

  
>  There's also a minor formatting issue, where Outlook will remove "extra
>line
>breaks" and compress the outputs of both php and http-error to a single
>line. This can be avoided by having a space printed before every message
>line.
>
>  

  We won't fix MUA issues (especially not outlook's).

  
>  Attached patch changes date_format to the same format as http-error and
>adds
>http-error LogFile to php.conf.
>Additionally it adds a new "Parse Errors" category and prints those as well
>and begins every message line with a space to avoid Outlook removing "extra
>break lines" (this same modification could be applied to http-error, the
>code is identical).
>
>Regarding Parse Errors category, I've placed it below warnings but it could
>as well be placed above it. Detail < 5 will skip last 2 categories, I can't
>really decide which 2 those should be or if another Detail level should be
>added...
>
>Regards,
>gulikoza
>
>  

  Thanks for reporting.

  Stefan

  
>     
>
>  
>
>  

  

 

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk

_______________________________________________
Logwatch-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/logwatch-devel
(unnamed) (text/plain, 177 B)
_______________________________________________
Logwatch-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/logwatch-devel
php.diff (text/x-patch, 2.2 KB)
Index: conf/services/php.conf
===================================================================
--- conf/services/php.conf	(revision 175)
+++ conf/services/php.conf	(working copy)
@@ -21,6 +21,7 @@
 
 # Which logfile group...
 LogFile = php
+LogFile = http-error
 
 # PHP notices should be fixed
 Detail = High
Index: scripts/services/php
===================================================================
--- scripts/services/php	(revision 175)
+++ scripts/services/php	(working copy)
@@ -36,7 +36,7 @@
 use Time::Local;
 use POSIX qw(strftime);
 
-my $date_format = '%d-%b-%Y %H:%M:%S';
+my $date_format = '... %b %d %H:%M:%S %Y';
 my $filter = TimeFilter($date_format);
 my $detail = exists $ENV{'LOGWATCH_DETAIL_LEVEL'} ? $ENV{'LOGWATCH_DETAIL_LEVEL'} : 0;
 
@@ -51,6 +51,7 @@
 # third element: anonymous hash ref (stores message  counts)
 my @message_categories = (['Fatal errors', qr/\] PHP Fatal error: (.*)$/o, {}],
 			  ['Warnings', qr/\] PHP Warning: (.*)$/o, {}],
+			  ['Parse Errors', qr/\] PHP Parse error: (.*)$/o, {}],
 			  ['Notices', qr/\] PHP Notice: (.*)$/o, {}]);
 
 # skipping categories depending on detail level
@@ -63,13 +64,13 @@
     my $line = $_;
     # skipping messages that are not within the requested range
     next unless $line =~ /^\[($filter)\]/o;
-    $1 =~ /(\d+)-(\w+)-(\d+) (\d+):(\d+):(\d+)/;
+    $1 =~ /(\w+) (\w+) (\d+) (\d+):(\d+):(\d+) (\d+)/;
     my $time;
 
     {
 	# timelocal is quite chatty
 	local $SIG{'__WARN__'}  = sub {};
-	$time = timelocal($6, $5, $4, $1, $month2num{$2}, $3-1900);
+	$time = timelocal($6, $5, $4, $3, $month2num{$2}, $7-1900);
     }
 
     foreach my $cur_cat (@message_categories) {
@@ -105,7 +106,7 @@
 
     foreach my $msg (@sorted_msgs) {
 	# grouping messages by number of occurrence
-	print "\n", $msgs->{$msg}->{'count'}, " times:\n" unless $last_count == $msgs->{$msg}->{'count'};
+	print "\n", $msgs->{$msg}->{'count'}, " times:\n " unless $last_count == $msgs->{$msg}->{'count'};
 	my $rms = 0;
 
 
@@ -140,7 +141,7 @@
 	    print strftime($date_format, localtime($msgs->{$msg}->{'first_occurrence'}));
 	}
 
-	print '] ', $msg, "\n";
+	print '] ', $msg, "\n ";
 	$last_count = $msgs->{$msg}->{'count'};
     }
(unnamed) (text/plain, 447 B)
------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.