README.md in ougai-1.4.1 vs README.md in ougai-1.4.2

- old
+ new

@@ -4,11 +4,11 @@ [![Gem Version](https://badge.fury.io/rb/ougai.svg)](https://badge.fury.io/rb/ougai) [![Build Status](https://travis-ci.org/tilfin/ougai.svg?branch=master)](https://travis-ci.org/tilfin/ougai) [![Code Climate](https://codeclimate.com/github/tilfin/ougai/badges/gpa.svg)](https://codeclimate.com/github/tilfin/ougai) [![Test Coverage](https://codeclimate.com/github/tilfin/ougai/badges/coverage.svg)](https://codeclimate.com/github/tilfin/ougai/coverage) -A JSON logging system is capable of handling a message, data or an exception easily. +A structured JSON logging system is capable of handling a message, structured data or an exception easily. It is compatible with [Bunyan](https://github.com/trentm/node-bunyan) for Node.js. It can also output human readable format for the console. ## Installation @@ -325,83 +325,10 @@ ### Screen result example ![Screen Shot](https://github.com/tilfin/ougai/blob/images/ougai_readable_format.png?raw=true) -## Use on Rails - -### Define a custom logger - -Add following code to `lib/your_app/logger.rb` -A custom logger includes LoggerSilence because Rails logger must support `silence` feature. - -```ruby -module YourApp - class Logger < Ougai::Logger - include ActiveSupport::LoggerThreadSafeLevel - include LoggerSilence - - def initialize(*args) - super - after_initialize if respond_to? :after_initialize - end - - def create_formatter - if Rails.env.development? || Rails.env.test? - Ougai::Formatters::Readable.new - else - Ougai::Formatters::Bunyan.new - end - end - end -end -``` - -### for Development - -Add following code to `config/environments/development.rb` - -```ruby -Rails.application.configure do - ... - - config.logger = YourApp::Logger.new(STDOUT) -end -``` - -### for Production - -Add following code to the end block of `config/environments/production.rb` - -```ruby -Rails.application.configure do - ... - - if ENV["RAILS_LOG_TO_STDOUT"].present? - config.logger = YourApp::Logger.new(STDOUT) - else - config.logger = YourApp::Logger.new(config.paths['log'].first) - end -end -``` - -### With Lograge - -You must modify [lograge](https://github.com/roidrage/lograge) formatter like *Raw*. -The following code set request data to `request` field of JSON. - -```ruby -Rails.application.configure do - config.lograge.enabled = true - config.lograge.formatter = Class.new do |fmt| - def fmt.call(data) - { msg: 'Request', request: data } - end - end -end -``` - ### Output example on development If you modify `application_controller.rb` as ```ruby @@ -435,9 +362,14 @@ :view => 3.35, :db => 0.0 } } ``` + +## How to use with famous products and libraries + +- [Use as Rails logger](https://github.com/tilfin/ougai/wiki/Use-as-Rails-logger) +- [Customize Sidekiq logger](https://github.com/tilfin/ougai/wiki/Customize-Sidekiq-logger) ## License [MIT](LICENSE.txt)