[wp-hackers] Re: yes, hide_errors but now log_errors too; if so, where?

Martin at Cleaver.org Martin at Cleaver.org
Sun Feb 11 21:51:58 GMT 2007

(16:25:08) *MartinCleaver:* I think my install is experiencing problems that
are muted by hide_errors
(16:25:21) *MartinCleaver:* I think that logging during errors would allow
me to diagnose
(16:25:38) *MartinCleaver:* I want the best approach for logging these
(16:25:59) *MartinCleaver:* This would go into function print_error($str =
(16:26:49) *MartinCleaver:* (in wp-db.php_
(16:26:51) *MartinCleaver:* )
(16:26:57) *MartinCleaver:* should I log to syslog? what class should I use?
Is there a reason why there is not currently logging in there?
(16:28:34) *zamoose:* Martin: what sorts of errors are you seeing?
(16:28:45) *zamoose:* or, rather, what are you expecting to see?
(16:29:22) *MartinCleaver:* well, I was getting errors (from shortstat)
appear in my RSS feed, but I had to suppress them there as they were
breaking the feed.
(16:30:00) *MartinCleaver:* So I know errors get generated at line 109:
(16:30:01) *MartinCleaver:* if ( $this->show_errors ) {
(16:30:01) *MartinCleaver:* // If there is an error then take note of it
(16:30:01) *MartinCleaver:* print "<div id='error'>
(16:30:01) *MartinCleaver:* <p class='wpdberror'><strong>WordPress database
error:</strong> [$str]<br />
(16:30:01) *MartinCleaver:* <code>$query</code></p>
(16:30:01) *MartinCleaver:* </div>";
(16:30:01) *MartinCleaver:* } else {
(16:30:01) *MartinCleaver:* return false;
(16:30:01) *MartinCleaver:* }
(16:30:18) *MartinCleaver:* since I suppressed using hide_errors they don't
get logged
(16:31:18) *MartinCleaver:* So I'm wanting to create an admin function so
that anything that causes an error ( shown or hidden from the web user) gets
logged for later use by the admin
(16:32:06) *MartinCleaver:* In some ways I am shying away from writing to
the database, as in some scenarios the failure would be with the database.
(16:32:18) *MartinCleaver:* also, log size could get out of hand
(16:32:24) *zamoose:* true
(16:32:27) *MartinCleaver:* and they should be rotated etc.
(16:32:33) *zamoose:* what purpose would logging these errors erve?
(16:32:37) *zamoose:* errrr serve, even
(16:32:59) *MartinCleaver:* I'm thinking if there are errors, real errors,
then they should be dealt with
(16:33:31) *MartinCleaver:* I suspect, for instance, when I exported a
database from one server to another that I lost all my auto_increment flags
(16:33:49) *MartinCleaver:* but I don't see errors, just failures to perform
(16:34:04) *MartinCleaver:* logging critical errors just seems like the
first next sane step
(16:34:16) *zamoose:* hmmm
(16:34:39) *MartinCleaver:* I appreciate that not all errors will actually
be errors
(16:35:30) *zamoose:* is this only affecting you, or are others seeing the
same thing?
(16:35:40) *chye-fhut:* does WordPress have it's own error handling or rely
on whatever PHP provides?
(16:35:56) *zamoose:* depends on which version of WP
(16:36:10) *MartinCleaver:* well it was affecting others - my RSS feed was
(16:36:13) *zamoose:* there's been a lot of error handling improvements that
have gone into 2.0 and 2.1
(16:36:25) *zamoose:* what web host are you using?
(16:36:28) *MartinCleaver:* I am on 2.0 based code
(16:36:36) *MartinCleaver:* using a powervps installation
(16:37:03) *MartinCleaver:* (my server actually runs wpmu, the multi-user
version, but this code line is identical)
(16:38:27) *zamoose:* okay, well, if you think that it's due to
auto_increment being incorrectly set, why not simply log in to your mysql
instance and run, say `desc wp_posts` in order to see if auto_increment is
listed in Extra?
(16:38:48) *MartinCleaver:* I think it affects every table
(16:39:00) *MartinCleaver:* and that does not protect against future errors
(16:39:10) *MartinCleaver:* I'm thinking I can syslog before this clause:
(16:39:26) *MartinCleaver:* // Is error output turned on or not..
(16:39:26) *MartinCleaver:* if ( $this->show_errors ) {
(16:39:37) *MartinCleaver:* that way errors would always be captured
(16:40:11) *zamoose:* true
(16:40:18) *zamoose:* just don't do it long-term
(16:40:27) *MartinCleaver:* like chye-fhut, I wonder which (php vs. wp)
facility to use
(16:40:35) *MartinCleaver:* sure, I could disable logging
(16:40:46) *MartinCleaver:* but there should be the option to turn it on
(16:41:47) *MartinCleaver:* I grepped the code for ' log' - but this
revealed nothing about a wp based logging system
(16:42:06) *MartinCleaver:* so I'm assuming (and I'd like confirming) that
wp does not have one
(16:43:33) *MartinCleaver:* and if noone knows, can someone suggest pros and
cons for a syslog php based one, and a library with which to log and a set
of tools with which to monitor and rotate the logs?

On 2/11/07, Martin at Cleaver.org <Martin at cleaver.org> wrote:
> In http://svns.automattic.com/wordpress/trunk/wp-includes/wp-db.php (and
> the wpmu equivalent)
> There exists:
> > 	function print_error($str = '') {
> > 		global $EZSQL_ERROR;
> > 		if (!$str) $str = mysql_error($this->dbh);
> > 		$EZSQL_ERROR[] =
> > 		array ('query' => $this->last_query, 'error_str' => $str);
> >
> >
> > 		$str = htmlspecialchars($str, ENT_QUOTES);
> > 		$query = htmlspecialchars($this->last_query, ENT_QUOTES);
> > 		// Is error output turned on or not..
> > 		if ( $this->show_errors ) {
> > 			// If there is an error then take note of it
> >
> > 			print "<div id='error'>
> > 			<p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br />
> > 			<code>$query</code></p>
> > 			</div>";
> >
> > 		} else {
> >
> >                     // AT HERE  I'm proposing adding logging to record muted error messages
> >
> >                                                 return false;
> >
> 		}
> > 	}
> >
> >
> As administrator, I'm concerned some of those errors might be symptomatic
> of a deep problem.
> Has anyone considered logging these hidden messages?
> Thanks,I think I need to do so, as something is amiss on my server, so
> what's the best logging mechanism to use? syslog? log to database? Is there
> a particular php / wordpress error logging class to use?
> Thanks,
>        Martin
> --
> Martin at Cleaver.org

Martin at Cleaver.org

More information about the wp-hackers mailing list