0.02
Low commit activity in last 3 years
No release in over a year
Extensions and enhancements to Ruby's built in Logger class. Extensions include: multiple output streams, JSON formatting for easy aggregation, and a Railtie to set some sane(ish) defaults for production Rails environments.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 6.1
>= 0
>= 0
~> 2.4.0

Runtime

 Project Readme

Paul Bunyan (formerly: Logging)

Gem Build Status Dependency Status

PaulBunyan is a re-usable component with a globally accessible Logger with extra support for handling logging in Rails.

class Foo
  include PaulBunyan

  def bar
    logger.warn "blah"
  end
end

Also included is a Railtie that overrides the default rails logger to always print to STDOUT as well as format the messages to JSON for machine readable goodness. This has been tested with Rails 4.2 through 5.1, older versions of Rails may work but are not guaranteed to and will not receive support.

Installation

Add this line to your application's Gemfile:

gem 'paul_bunyan'

And then execute:

$ bundle

Or install it yourself as:

$ gem install paul_bunyan

Usage

Non-Rails projects:

require 'paul_bunyan'

include PaulBunyan

logger.warn "blah"

Rails projects:

Nothing after it's added to your Gemfile, the Railtie takes care of the rest.

Adding metadata to JSON logs

The default logger includes the ability to accept arbitrary metadata, the primary use case for this functionality is to add context to log lines generated in the course of processing a Rails request. There is an example for adding the request host to the metadata in the examples directory. There are a few keys that are used internally that will be overwritten when added to user supplied metadata, this list can be found in the #call method of PaulBunyan::JSONFormatter.

Seeing what your server logs will look like in the console

To do this set PB_DISABLE_CONSOLE_OVERRIDE in your environment: PB_DISABLE_CONSOLE_OVERRIDE=1 bundle exec rails c