logString .= $errorString; } if ((!defined('IGNORE_LOG_LEVEL_WRITE')) && ($logno <= LOG_LEVEL_WRITE)) { $filename = 'logfile.txt'; if (is_writable($filename)) { //Check if the file can be opened if (!$handle = fopen($filename, 'w')) { define('IGNORE_LOG_LEVEL_WRITE', true); trigger_log(SYSLOG_EMERG, 'Cannot open file "' . $filename . '"', __FILE__, __LINE__); exit; } // Write $errorString to file. if (fwrite($handle, $errorString) === FALSE) { define('LOG_LEVEL_WRITE', LOG_LEVEL_NONE); trigger_log(SYSLOG_EMERG, 'Cannot write to "' . $filename . '"', __FILE__, __LINE__); exit; } fclose($handle); } else { define('IGNORE_LOG_LEVEL_WRITE', true); trigger_log(SYSLOG_EMERG, 'Cannot write to "' . $filename . '"', __FILE__, __LINE__); } } if ($logno <= LOG_LEVEL_MAIL) { mail('test@test.com', 'Nodemap error', $errorString); } } function __destruct() { echo ''; } } $LOG_HANDLER = new LogHandler(); /* * Function: trigger_log * Parameters: int $logno, string $logstr, string $logfile, int $logline * Function: Handling with log entries, forwarding them to our $LOG_HANDLER object. */ function trigger_log($logno, $logstr, $logfile, $logline) { global $LOG_HANDLER; $LOG_HANDLER->logEntry($logno, $logstr, $logfile, $logline); } ?>