public static function fromBacktrace($config, $backtrace, $topFile, $topLine) { $stacktrace = new Wapplogs_Stacktrace($config); // PHP backtrace's are misaligned, we need to shift the file/line down a frame foreach ($backtrace as $frame) { if (!self::frameInsideWapplogs($frame)) { $stacktrace->addFrame($topFile, $topLine, $frame['function'], isset($frame['class']) ? $frame['class'] : null); } if (isset($frame['file']) && isset($frame['line'])) { $topFile = $frame['file']; $topLine = $frame['line']; } else { $topFile = "[internal]"; $topLine = 0; } } // Add a final stackframe for the "main" method $stacktrace->addFrame($topFile, $topLine, '[main]'); return $stacktrace; }
public function setPHPError($code, $message, $file, $line, $fatal = false) { if ($fatal) { // Generating stacktrace for PHP fatal errors is not possible, // since this code executes when the PHP process shuts down, // rather than at the time of the crash. // // In these situations, we generate a "stacktrace" containing only // the line and file number where the crash occurred. $stacktrace = Wapplogs_Stacktrace::fromFrame($this->config, $file, $line); } else { $stacktrace = Wapplogs_Stacktrace::generate($this->config); } $this->setName(Wapplogs_ErrorTypes::getName($code))->setMessage($message)->setSeverity(Wapplogs_ErrorTypes::getSeverity($code))->setStacktrace($stacktrace)->setCode($code); return $this; }