aliroErrorRecorder Class Reference

Inheritance diagram for aliroErrorRecorder:

aliroDatabaseRow aliroDBGeneralRow

List of all members.

Public Member Functions

 PHPerror ($errno, $errstr, $errfile, $errline, $errcontext)
 recordError ($smessage, $errorkey, $lmessage='', $exception=null)

Static Public Member Functions

static getInstance ($request=null)

Protected Attributes

 $DBclass = 'aliroCoreDatabase'
 $tableName = '#__error_log'
 $rowKey = 'id'

Static Protected Attributes

static $instance = null


Detailed Description

Definition at line 45 of file aliroErrorRecorder.php.


Member Function Documentation

static aliroErrorRecorder::getInstance ( request = null  )  [static]

Definition at line 51 of file aliroErrorRecorder.php.

Referenced by aliroExtensionInstaller::doPackageCode(), aliroSession::handleCoreDumps(), aliroExtensionInstaller::install(), aliroAbstractRequest::invokeComponent(), aliroLanguageBasic::load(), and aliro::startup().

00051                                                        {
00052         return (null == self::$instance) ? (self::$instance = new self()) : self::$instance;
00053     }

aliroErrorRecorder::PHPerror ( errno,
errstr,
errfile,
errline,
errcontext 
)

Definition at line 55 of file aliroErrorRecorder.php.

References aliroRequest::getInstance(), recordError(), and T_().

00055                                                                                 {
00056         if (!($errno & error_reporting())) return;
00057         $rawmessage = function_exists('T_') ? T_('PHP Error %s: %s in %s at line %s') : 'PHP Error %s: %s in %s at line %s';
00058         $message = sprintf($rawmessage, $errno, $errstr, $errfile, $errline);
00059         $lmessage = $message;
00060         if (is_array($errcontext)) {
00061             foreach ($errcontext as $key=>$value) if (!is_object($value) AND !(is_array($value))) $lmessage .= "; $key=$value";
00062         }
00063         $errorkey = "PHP/$errno/$errfile/$errline/$errstr";
00064         $this->recordError($message, $errorkey, $lmessage);
00065         aliroRequest::getInstance()->setErrorMessage(T_('A PHP error has been recorded in the log'), _ALIRO_ERROR_WARN);
00066         if ($errno & (E_USER_ERROR|E_COMPILE_ERROR|E_CORE_ERROR|E_ERROR)) die (T_('Serious PHP error - processing halted - see error log for details'));
00067     }

aliroErrorRecorder::recordError ( smessage,
errorkey,
lmessage = '',
exception = null 
)

Definition at line 69 of file aliroErrorRecorder.php.

References aliroCoreDatabase::getInstance(), aliroDBGeneralRow::store(), timestamp, and aliroRequest::trace().

Referenced by PHPerror().

00069                                                                                       {
00070         $this->id = 0;
00071         $this->timestamp = date ('Y-m-d H:i:s');
00072         $this->smessage = $smessage;
00073         $this->lmessage = $lmessage ? $lmessage : $smessage;
00074         $this->referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
00075         $database = aliroCoreDatabase::getInstance();
00076         $this->errorkey = $database->getEscaped($errorkey);
00077         $this->get = $_SERVER['REQUEST_URI'];
00078         $this->post = base64_encode(serialize($_POST));
00079         $this->trace = aliroRequest::trace();
00080         if ($exception instanceof databaseException) {
00081             $this->dbname = $exception->dbname;
00082             $this->sql = $exception->sql;
00083             $this->dberror = $exception->getCode();
00084             $this->dbmessage = $exception->getMessage();
00085             $this->dbtrace = $exception->dbtrace;
00086         }
00087         else $this->dbname = $this->sql = $this->dberror = $this->dbmessage = null;
00088         $database->setQuery("SELECT id FROM #__error_log WHERE errorkey = '$this->errorkey'");
00089         $id = $database->loadResult();
00090         if (!$id) $this->store();
00091         else $database->doSQL("UPDATE #__error_log SET timestamp = NOW() WHERE id = $id");
00092         // code to prune error log - limit to max items, max days
00093         $database = call_user_func(array($this->DBclass, 'getInstance'));
00094         $database->doSQL("DELETE LOW_PRIORITY FROM $this->tableName WHERE timestamp < SUBDATE(NOW(), INTERVAL 7 DAY)");
00095     }


Member Data Documentation

aliroErrorRecorder::$instance = null [static, protected]

Definition at line 46 of file aliroErrorRecorder.php.

aliroErrorRecorder::$DBclass = 'aliroCoreDatabase' [protected]

Definition at line 47 of file aliroErrorRecorder.php.

aliroErrorRecorder::$tableName = '#__error_log' [protected]

Definition at line 48 of file aliroErrorRecorder.php.

aliroErrorRecorder::$rowKey = 'id' [protected]

Definition at line 49 of file aliroErrorRecorder.php.


The documentation for this class was generated from the following file:

Generated on Wed May 14 13:01:58 2008 for ALIRO by  doxygen 1.5.5