This article was sponsored by Rollbar. Thank you for supporting the sponsors who make SitePoint possible.
As a SitePoint reader, you write perfect error-free code on every project…
But can you say the same for every member of your team?
The more sophisticated your product, the larger your team and the more bugs you’ll discover. You may have robust testing procedures, but can you be sure the latest edition of your framework is error-free? What about third-party modules, databases and components? Is the language or runtime perfect? Are you certain about the underlying deployment Operating System? Can the whole stack be considered fool-proof for the most foolish of users?!
Understanding that errors are inevitable is the first step. The considerably more complex second step is recording errors, tracking frequencies, prioritizing issues, coding a solution, testing the fixes and deploying to a live server. Without careful management, teams can spend longer fixing bugs than writing new code.
Fortunately, Rollbar can drastically reduce debugging time and costs. The service is trusted by companies such as Heroku, Walmart, LogMeIn, Lyft, Twitch and Intuit to centrally manage critical errors on web sites, web applications, mobile and desktop apps.
At the time of writing, Rollbar has logged almost 13 billion errors (and that’s just my shoddy code!).
Debugging the Rollbar Way
Rollbar unites your tools into one seamless error-handling workflow. A few minutes of set-up can save considerable effort over the longer term.
1. Sign Up
Sign up from the Rollbar home page for an initial free trial. You can use an email address or link your GitHub account.
A quick set-up guide runs the first time you log in.
2. Create a New Project
Enter a project name and choose from one of the many languages and frameworks. All popular mobile, desktop and web back and front-end platforms are available.
On creation, your project is assigned a unique access token which identifies all messages sent to the Rollbar system.
3. Integrate Rollbar into Your Project
Integration will vary according to your project’s language. For PHP, you can install a Rollbar component using Composer or by downloading two files. Include rollbar.php, initialize and send a test message:
<?php
// include Rollbar component
require_once 'rollbar.php';
// initialize Rollbar
Rollbar::init(array('access_token' => 'your-project-token'));
// send a test message
Rollbar::report_message('testing 123', 'info');
You can then add one or more exception handlers to capture all errors:
// catch exception and send to Rollbar
try {
throw new Exception('test exception');
} catch (Exception $e) {
Rollbar::report_exception($e);
}
For Node.js Express projects, you can install the Rollbar module using npm:
npm install --save rollbar
Then add Rollbar error-handling middleware:
var
rollbar = require('rollbar'),
express = require('express'),
app = express();
// Rollbar middleware
app.use(rollbar.errorHandler('your-project-token'));
// basic route
app.get('/', function (req, res) {
res.send('Hello World!');
});
// start server
app.listen(3000);
Rollbar provides notification libraries for Android, Clojure, ColdFusion, Dart, Erlang, Flash, Go, Haskell, iOS, Java, JavaScript (client), .NET, Node.js, PHP, Python, Ruby and web server logs. Alternatively, you can use the fully documented RESTful API for other languages.
4. Access Your Rollbar Dashboard
The Rollbar dashboard provides a live overview of all errors with the frequency of occurrence:
Continue reading %How to Improve Your Team’s Debugging Times with Rollbar%