handle the case of the SQL log failing to open

This commit is contained in:
Shish 2009-11-15 10:26:17 +00:00
parent 50cf3baca9
commit 7f47c594c8

View file

@ -245,14 +245,19 @@ function check_cli() {
function _count_execs($db, $sql, $inputarray) {
global $_execs;
if(DEBUG) {
$fp = fopen("sql.log", "a");
if(is_array($inputarray)) {
fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)." -- ".join(", ", $inputarray)."\n");
$fp = @fopen("sql.log", "a");
if($fp) {
if(is_array($inputarray)) {
fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)." -- ".join(", ", $inputarray)."\n");
}
else {
fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)."\n");
}
fclose($fp);
}
else {
fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)."\n");
log_error("core", "failed to open sql.log for appending");
}
fclose($fp);
}
if (!is_array($inputarray)) $_execs++;
# handle 2-dimensional input arrays
@ -422,6 +427,13 @@ function log_info($section, $message) {
log_msg($section, LOG_INFO, $message);
}
/**
* A shorthand way to send a LogEvent
*/
function log_error($section, $message) {
log_msg($section, LOG_ERROR, $message);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* Things which should be in the core API *