public function sendToServer($type, $subject, $number, $message, $file, $line) { // $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, 'Executing...'); // $this->_logVerbose('Executing...'); if ($this->_isTraceDefined()) { $trace = anvilFuseTrace::render(); // $this->_firePHP->_log('Trace Defined'); if ($this->echoTrace && $type > self::TRACE_TYPE_DEBUG) { echo nl2br($message); echo anvilFuseTrace::renderHTML(); echo '<hr />'; } } if ($this->isFireBugEnabled()) { // $this->_firePHP->_log(array($type, $subject, $number, $message, $file, $line, $trace)); } if ($this->isServerEnabled()) { // $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, 'Opening Connection to anvilFuseTrap Server...'); $this->_logVerbose('Opening Connection to anvilFuseTrap Server...'); try { $anvilFuseWS = new SoapClient($this->serverURL); // $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, 'Adding new event...'); // $this->_logVerbose('Adding new event...'); $return = $anvilFuseWS->newEvent($type, $this->applicationID, $this->applicationVersion, $this->_remoteIP, $subject, $number, $message, $file, $line, $trace); return $return; } catch (SoapFault $fault) { $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, 'Server communications failure! (' . $fault->faultcode . ' - ' . $fault->faultstring . ')'); } catch (Exception $exception) { $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, 'Server communications failure! (' . $exception->getCode() . ' - ' . $exception->getMessage() . ')'); } #---------------------------------------- } elseif ($this->isDatabaseEnabled()) { // $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, 'Opening Connection to Database...'); $this->_logVerbose('Opening Connection to Database...'); try { // $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, 'starting...'); // $this->_logVerbose('starting...'); if ($this->tableVersion === 1) { $objEvent = new anvilFuseEvent($this->dataConnection, $this->tableName); $objEvent->eventTypeID = $type; $objEvent->applicationID = $this->applicationID; } else { $objEvent = new anvilFuseEvent2($this->dataConnection, $this->tableName); $objEvent->fuseEventTypeID = $type; $objEvent->fuseApplicationID = $this->applicationID; } $objEvent->version = $this->applicationVersion; $objEvent->userIP = $this->_remoteIP; $objEvent->userID = $this->userID; $objEvent->name = substr($subject, 0, 255); $objEvent->number = $number; $objEvent->details = $message; $objEvent->file = $file; $objEvent->line = $line; $objEvent->trace = $trace; // $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, 'Save SQL = ' . $objEvent->buildSaveSQL()); $objEvent->save(); $return = array('result' => '1', 'junk' => 'junk'); // $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, '$return=' . var_export($return, true)); return $return; } catch (Exception $exception) { // $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, 'Server communications failure! (' . $exception->getCode() . ' - ' . $exception->getMessage . ")\n[" . $exception->getTraceAsString() . ']'); $this->_logError('Server communications failure! (' . $exception->getCode() . ' - ' . $exception->getMessage() . ')'); } } elseif (!empty($this->_logPath)) { $types = array(0 => 'Other', 10 => 'Test', 20 => 'Info', 30 => 'Debug', 40 => 'Warning', 50 => 'Error', 60 => 'Critical'); try { $log = fopen($this->_logPath, 'ab'); $logAppend = "-------------------------------------------------------\r\n"; $logAppend .= 'DTS: ' . date('Y-m-d H:i:s') . "\r\n"; $logAppend .= 'Type: ' . $types[$type] . "\r\n"; $logAppend .= 'Application ID: ' . $this->applicationID . "\r\n"; $logAppend .= 'Application version: ' . $this->applicationVersion . "\r\n"; $logAppend .= 'User IP: ' . $this->_remoteIP . "\r\n"; $logAppend .= 'Number: ' . $number . "\r\n"; $logAppend .= 'Name: ' . $subject . "\r\n"; $logAppend .= 'Details: ' . $message . "\r\n"; $logAppend .= 'File: ' . $file . "\r\n"; $logAppend .= 'Line: ' . $line . "\r\n"; $logAppend .= "\r\n"; $logAppend .= $trace; $logAppend .= "-------------------------------------------------------\r\n\r\n\r\n\r\n"; fwrite($log, $logAppend); fclose($log); $return = array('result' => '1', 'junk' => 'junk'); return $return; } catch (Exception $exception) { // $this->_addTraceInfo(__FILE__, __METHOD__, __LINE__, 'Server communications failure! (' . $exception->code . ' - ' . $exception->message . ')'); $this->_logError('Server communications failure! (' . $exception->getCode() . ' - ' . $exception->getMessage() . ')'); } } else { return false; } }
* * @author Nick Slevkoff <*****@*****.**> * @copyright Copyright (c) 2010 Nick Slevkoff (http://www.slevkoff.com) * @license * This source file is subject to the new BSD license that is * bundled with this package in the file LICENSE.txt. It is also * available on the Internet at: http://www.phpanvil.com/LICENSE.txt * @ingroup phpAnvilTools anvilFuse */ //---- phpAnvil Fuse require_once 'anvilFuseEvent.class.php'; require_once 'anvilFuseEvent2.class.php'; require_once 'anvilFuseTrace.class.php'; require_once 'anvilFuseTrap.class.php'; //DevTrace::enableFullPath(); anvilFuseTrace::start(); $objFuseTrap = new anvilFuseTrap(); $objFuseTrap->onError(anvilFuseTrap::EVENT_TYPE_ERROR, array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR), '', true); $objFuseTrap->onError(anvilFuseTrap::EVENT_TYPE_WARNING, array(E_WARNING, E_PARSE, E_NOTICE, E_CORE_WARNING, E_COMPILE_WARNING, E_USER_WARNING)); $objFuseTrap->onError(anvilFuseTrap::EVENT_TYPE_DEBUG, array(E_STRICT)); //$objFuseTrap->applicationID = DEVTRAP_APPLICATION_ID; //$objFuseTrap->applicationVersion = DEVTRAP_APPLICATION_VERSION; //$objFuseTrap->serverURL = 'http://www.devtrap.com/ws.wsdl'; //$objFuseTrap->enableServer(); //$objFuseTrap->enableTrace(); //$objFuseTrap->start(); function emailDebugTrace() { sendDebugTrace('The function emailDebugTrace has been replaced by sendDebugTrace.'); } function sendDebugTrace($message = '')
/** * Starts the tracing session. * */ public static function start() { self::$_startTime = microtime(true); }
/** * 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; } } }