Progstr » logger is a service that collects and manages programmer log entries in the cloud. Most web applications log errors and special external events generated by users or third party systems. Progstr » logger takes away the pain of complex logging system configurations, provides a centralized location for all your log entries and helps you analyze the data you've collected over time. progstr-ruby is the Ruby client library that collects log entries and transports them to the Progstr data store.

Installation

Install the progstr-ruby gem on your system:

gem install progstr-ruby

Or even better - add it to your bundler configuration by adding this to your Gemfile:

gem "progstr-ruby"

progstr-ruby is a regular Ruby gem that you add to your application. Here is how you integrate it in your project:

  • Sign up for progstr » logger and obtain an API token. That token is used to identify you against the service. Keep it secret and do not share it with anyone unless you want to let them log messages on your behalf.
  • Install the progstr-ruby gem on your system or add it to your bundler configuration.
  • Configure the API token by setting the Progstr.api_key property before you start logging:
    
    Progstr.api_key = "6f413b64-a8e1-4e25-b9e6-d83acf26ccba"
    
  • (Optional) Set up Rails, so that it sends logs to the Progstr service by changing your respective environment configuration. For example, add this to your config/environments/production.rb:
    
    Progstr.api_key = "6f413b64-a8e1-4e25-b9e6-d83acf26ccba"
    Progstr::RailsLogger.start config
    

Getting started

There are four log severity levels that you can use to log events of different importance:

  • Info: used to log general information events that can be used for reference or troubleshooting if needed.
  • Warning: something odd happened and somebody needs to know about it.
  • Error: something failed and needs to be fixed.
  • Fatal: the entire application or a critical part of it is not working at all.

To log an event you need to create a Progstr::Logger object and call some of its info/warn/error/fatal methods. You need to provide the logger source name as a constructor parameter. That will be used to categorize logs and make it easier for you to find specific entries:

require 'progstr'
...
...
home_log = Progstr::Logger.new("HomeController")
...
home_log.info(message);
...
home_log.warn(message);
...
home_log.error(message);
...
home_log.fatal(message);

A Progstr::Logger object is really a standard Ruby Logger. That means you can also check the current log level or do conditional logging using blocks that are evaluated only if the respective level has been enabled. For example, to construct a log message and log it only if info logging has been enabled, you can do this:

home_log.info { "Assemble " + "a complex log message here: #{user.name}" }

Alternatively, you can override the source name by passing the progname parameter to log methods:

home_log.warn("other-source") { "Oops, I need to warn somebody!" }

If you have configured Rails to send all logs to our service, you can simply use the Rails.logger object to log:

Rails.logger.info("HomeController#index called")

Note: Ruby Logger objects also support debug-level logs. progstr-ruby will convert those to info logs.

Supported platforms

  • Ruby 1.8.7 and later

Documentation

Available online here.