/** * Adds a log entry to the log %router. * * @param string $detail * The full details of the log entry or a variable. * @param string $title * (optional) A short name describing the subject or title of the log * entry. * @param integer $logLevel * (optional) The importance level of the log entry. * @return NULL */ protected function _log($detail, $title = '', $logLevel = self::LOG_LEVEL_DEBUG) { global $phpAnvil; if (isset($phpAnvil) && is_object($phpAnvil) && $logLevel <= $this->logLevel && $this->isLogEnabled()) { $backTrace = debug_backtrace(); //---- Add to anvilFuseTrace ------------------------------------------ if ($this->_isTraceDefined()) { if (!empty($title)) { $traceInfo = $title . ' = ' . $detail; } else { $traceInfo = $detail; } anvilFuseTrace::add($backTrace[1]['file'], $backTrace[2]['class'] . '::' . $backTrace[2]['function'], $backTrace[1]['line'], $traceInfo, $logLevel); } // $extendedTitle = '[' . $backTrace[2]['class'] . '->' . $backTrace[2]['function'] . ': Line ' . $backTrace[1]['line'] . '] ' . $title; $extendedTitle = $backTrace[2]['class'] . '->' . $backTrace[2]['function'] . ' (' . $backTrace[1]['line'] . ') ' . $title; //---- Output to FirePHP/FireBug ----------------------------------- switch ($logLevel) { case self::LOG_LEVEL_DEBUG: fb::log($detail, $extendedTitle); break; case self::LOG_LEVEL_BRIEF_INFO: case self::LOG_LEVEL_VERBOSE_INFO: fb::info($detail, $title); break; case self::LOG_LEVEL_WARNING: fb::warn($detail, $extendedTitle); break; case self::LOG_LEVEL_ERROR: case self::LOG_LEVEL_CRITICAL: // for ($i=0; $i < 3; $i++) { // fb::log($backTrace[$i]['file'], '$backTrace[' . $i . '][file]'); // fb::log($backTrace[$i]['class'], '$backTrace[' . $i . '][class]'); // fb::log($backTrace[$i]['function'], '$backTrace[' . $i . '][function]'); // fb::log($backTrace[$i]['line'], '$backTrace[' . $i . '][line]'); // } fb::error($detail, $title); $errorLocation = $backTrace[1]['file']; $errorLocation .= ': ' . $backTrace[2]['class']; $errorLocation .= '->' . $backTrace[2]['function']; $errorLocation .= ': Line ' . $backTrace[1]['line']; fb::error($errorLocation); break; } } }
public function open($persistent = true) { $return = false; if (!isset($this->_connection) || isset($this->_connection) && !$this->isConnected()) { $msg = 'Opening Database Connection...'; fb::info($msg); $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, $msg); $this->_connection = mssql_connect($this->server, $this->username, $this->password); if (!$this->_connection) { $errorMsg = mssql_get_last_message(); if (empty($errorMsg)) { $errorMsg = 'Unable to connect to server: ' . $this->server; } $this->errorMessages[] = $errorMsg; $msg = 'Unable to establish a database connection.'; fb::error($msg); $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, $msg); } else { $return = mssql_select_db($this->database, $this->_connection); $lastErrorMsg = mssql_get_last_message(); if (!$return) { $msg = 'Unable to select the database, ' . $this->database . '...'; fb::error($msg); $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, $msg); $this->errorMessages[] = $lastErrorMsg; } } } return $return; }
function out($message, $group, $color) { \fb::info($message, $group); }