Skip to content
A json logger for Rails
Ruby Shell
Branch: master
Clone or download
Latest commit 394718b Jul 22, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
lib Bump to version 0.1.1 Jul 22, 2019
spec Add test Jul 18, 2019
.gitignore
.rspec
.travis.yml Update ruby version for travis Jul 18, 2019
CODE_OF_CONDUCT.md first commit Dec 16, 2017
Gemfile first commit Dec 16, 2017
LICENSE.txt first commit Dec 16, 2017
README.md Fix travis url in README and add release badge Jul 18, 2019
Rakefile first commit Dec 16, 2017
logist.gemspec Remove bundler dependency Jul 18, 2019

README.md

Logist

Build Status Gem Version GitHub release

This gem provides json format for logger in Rails. Logist output json log like this:

$ bundle exec rails s -b 0.0.0.0
=> Booting Puma
=> Rails 5.1.4 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.10.0 (ruby 2.4.2-p198), codename: Russell's Teapot
* Min threads: 1, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
{"level":"INFO","timestamp":"2017-12-18T08:55:19+00:00","message":"hoge","environment":"development"}
{"level":"INFO","timestamp":"2017-12-18T08:55:19+00:00","environment":"development","method":"GET","path":"/api/health_check","format":"html","controller":"Api::HealthCheckController","action":"index","status":200,"duration":1.89,"view":0.81,"db":0.0,"exception":null,"exception_object":null}

Installation

Add this line to your application's Gemfile:

gem 'logist'

And then execute:

$ bundle

Or install it yourself as:

$ gem install logist

Usage

You have to use logist logger in your config/evnrionments/[rails-env].rb:

Rails.application.configure do
  # ...
  config.logger = Logist::Logger.new(STDOUT)
end

You can change logger configuration like this:

Rails.application.configure do
  # ...
  config.logger = Logist::Logger.new(STDOUT, datetime_format: "%Y-%m-%dT%H:%M:%S%:z:")
end

or

Rails.application.configure do
  # ...
  config.logger = Logist::Logger.new(STDOUT)
  config.logger.formatter.datetime_format = "%Y-%m-%dT%H:%M:%S%:z"
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/h3poteto/logist. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Logist project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

You can’t perform that action at this time.