No commit activity in last 3 years
No release in over 3 years
Make your Rails app log in JSON Format.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.7
~> 10.0
~> 3
 Project Readme

NiboshiJsonFormatter

Circle CI

A Ruby gem that makes your app log in JSON format. It may be useful if you ship all your logs to ElasticSearch.

Installation

Add this line to your application's Gemfile:

gem 'niboshi_json_formatter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install niboshi_json_formatter

Usage

Rails project

Add this to your config/environments/*.rb:

config.log_formatter = Niboshi::JsonFormatter.new

Logger

Update the formatter:

require 'niboshi_json_formatter'
@log = Logger.new(STDOUT)
@log.formatter = Niboshi::JsonFormatter.new
@log.info "foo bar"

#=> {"time":1417595700.318135,"formatted_time":"2014-12-03 17:35:00 +0900","hostname":"macmini.local","pid":66419,"tid":70165887050860,"level":"INFO","program_name":null,"message":"foo bar"}

Contributing

  1. Fork it ( https://github.com/[my-github-username]/niboshi_json_formatter/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request