public function log(IEvent $e) { $level = $e->getStr('level'); if (Log::logLevelAllowed($level, $this->_logLevel)) { // "critical", "error", "warning", "info", "debug" switch ($level) { case LogLevel::EMERGENCY: case LogLevel::ALERT: case LogLevel::CRITICAL: $level = 'critical'; break; case LogLevel::ERROR: $level = 'error'; break; case LogLevel::WARNING: $level = 'warning'; break; case LogLevel::DEBUG: $level = 'debug'; break; case LogLevel::NOTICE: case LogLevel::INFO: default: $level = 'info'; break; } $data = ['file' => $e->getStr('file'), 'line' => $e->getStr('line'), 'context' => $e->getArr('context')]; if (CUBEX_CLI) { $data['cli_command'] = implode(' ', $_SERVER['argv']); } \Rollbar::report_message($e->getStr('message'), $level, $data); } }
public function testFlush() { Rollbar::init(self::$simpleConfig); $this->assertEquals(0, Rollbar::$instance->queueSize()); Rollbar::report_message("Hello world"); $this->assertEquals(1, Rollbar::$instance->queueSize()); Rollbar::flush(); $this->assertEquals(0, Rollbar::$instance->queueSize()); }
protected function processLogs($logs) { foreach ($logs as $log) { // Exclude records by the exceptions handler. RollbarErrorHandler takes care of them. if (strncmp($log[2], 'exception', 9) !== 0) { Rollbar::report_message($log[0], $this->correspondingLevel($log[1])); } } }
function errorHandler($n, $m, $f, $l) { require_once 'errorsend.php'; $config = array('access_token' => 'a4073d551fb44087b5ebeea61588bbc4', 'environment' => 'production', 'root' => $_SERVER['DOCUMENT_ROOT']); Rollbar::init($config); Rollbar::report_message($m, 'error'); $str = 'phperror.php?n=' . urlencode($n) . '&m=' . urlencode($m) . '&f=' . urlencode($f) . '&l=' . urlencode($l); header('Location: ' . $str); }
/** * Initialize Rollbar. */ public function init() { // Require Rollbar vendor code require_once __DIR__ . '/vendor/autoload.php'; // Initialize Rollbar \Rollbar::init(array('access_token' => craft()->config->get('accessToken', 'rollbar'), 'environment' => CRAFT_ENVIRONMENT), false, false); // Log Craft Exceptions to Rollbar craft()->onException = function ($event) { \Rollbar::report_exception($event->exception); }; // Log Craft Errors to Rollbar craft()->onError = function ($event) { \Rollbar::report_message($event->message); }; }
private function reportRollbar($logEntry) { if ($this->rollbarEnabled && $logEntry['severity'] <= WATCHDOG_ERROR) { switch ($logEntry['severity']) { case WATCHDOG_ERROR: $severity = 'error'; break; case WATCHDOG_EMERGENCY: case WATCHDOG_ALERT: case WATCHDOg_CRITICAL: $severity = 'critical'; break; } $message = self::formatMessage($logEntry); Rollbar::report_message($message, $severity); } }
function main() { $config = array('access_token' => 'ad865e76e7fb496fab096ac07b1dbabb', 'environment' => 'test', 'root' => '/Users/brian/www/rollbar-php', 'logger' => new EchoLogger(), 'error_sample_rates' => array(E_NOTICE => 0.5, E_USER_ERROR => 1, E_USER_NOTICE => 0.5), 'person_fn' => 'get_current_person', 'included_errno' => E_USER_ERROR | E_USER_NOTICE); // $config, $set_exception_handler, $set_error_handler Rollbar::init($config, true, true); try { throw_test_exception("yo"); } catch (Exception $e) { Rollbar::report_exception($e); } Rollbar::report_message("hey there", "info"); Rollbar::report_message("hey there", "info", array("extra" => "data"), array("fingerprint" => "test fingerprint", "title" => "test title")); trigger_error("test user warning", E_USER_WARNING); trigger_error("test user notice", E_USER_NOTICE); trigger_error("test user error", E_USER_ERROR); // raises an E_NOTICE, reported by the error handler $foo = $bar2; // reported by the exception handler throw new Exception("uncaught exception"); }
public function report($message, $level = self::ERROR, $extraData = NULL, $payloadData = NULL) { \Rollbar::report_message($message, $level, $extraData, $payloadData); }