Olo

Olo is short for Obvious Logger. It allows developers to output a decorated version of an Object (String, Integer, Class, etc) in the rails console.

Best practice is to use Olo in development mode or custom mode (staging, profile, etc.). Using in production could have nasty consequences and just isn't worth the headaches.

Install

You can add Olo as a gem:

gem install o_lo

or add it to a Gemfile (Bundler):

gem 'o_lo', group: 'development'

Usage

Olo is set up to work from any controller, model, or view.

In a controller or model:

Olo.log("something to log", "%", 100)

In a view

#ERB
<% meaningful_variable = User.email %>
<% Olo.log(meaningful_variable, ":", 42) %>

#HAML
- meaningful_variable = User.email
- Olo.log(meaningful_variable, ":", 42)

The arguments for Olo.log are:

  • thing: The string, variable, or value of a thing you want to output to the stdout logs (* required)
  • decorator: Any string value that will be repeated to provide a visual way to find the output log (optional, default is "*")
  • decorator: length: How many times the decorator will be repeated. The max is 200. (optional, default is 100)

Output

thing = "Thanks for all the fish"
decorator = "ß"
decorator_length = 42
Olo.log(thing, decorator, decorator_length)
# output