chihiro 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60f175c477cd3d788cb1063d1b6e4be8921c4ce6fd61cc18d9b9d4a538545c6a
4
- data.tar.gz: a675f4673b58aef02d396a6e880497fcc9910b085154ccb99e51d48a5e28e320
3
+ metadata.gz: b02e72d647ea1919e47c783bf04a46a4a239b0e7d22d97723491e4be03d06ec8
4
+ data.tar.gz: b59dcbe80d7d1f2363cd85db1c4179bd79a3b63175ea2ed103cbf593bc835a28
5
5
  SHA512:
6
- metadata.gz: 49021a5f1292c4fc39bf78c04aa3f6ad605f45092f1b814b3ce16d0ed591482513cd9d3e2b44cd9066a1eeb3ad0eef2f15175f1e6b839f6a2241d5bdf02be7d3
7
- data.tar.gz: 5a74417f9554ef60bed1c6a60abf684a133da9331fb8bedc168b626e6de18c8ee6c5f002dd8fb162db9a82dac38e6bc21ae76501ad3bc53fae09600f632f4512
6
+ metadata.gz: b19306ae9f799370cd051693d0435aea38fc79479843a610a472963a205e382f4d088a9e6b6bf745c8dcc164065c2a20c5e9536675f75ebed13f2e4a7471bfb2
7
+ data.tar.gz: 2b737de4c58abce1d4b34d16803a28b7c1db88dc784e3667228f853f8019cb7f67ce92e14d1d5a226d6be5e205fc1a6667a91d0dd969b77c44c86a23987a95ce
data/Gemfile CHANGED
@@ -1,6 +1,8 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  # Specify your gem's dependencies in chihiro.gemspec
6
8
  gemspec
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Chihiro
1
+ # Chihiro, a Rails log formatter
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/chihiro`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Chihiro is a Rails log formatter that focuses on format rails log to json
6
4
 
7
5
  ## Installation
8
6
 
@@ -20,15 +18,9 @@ Or install it yourself as:
20
18
 
21
19
  $ gem install chihiro
22
20
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- 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.
21
+ ## Quick Start
30
22
 
31
- 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](https://rubygems.org).
23
+ add `Chihiro::Initializer.new.execute` to your `application.rb`
32
24
 
33
25
  ## Contributing
34
26
 
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/chihiro.gemspec CHANGED
@@ -1,25 +1,27 @@
1
1
 
2
- lib = File.expand_path("../lib", __FILE__)
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path('lib', __dir__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "chihiro/version"
6
+ require 'chihiro/version'
5
7
 
6
8
  Gem::Specification.new do |spec|
7
- spec.name = "chihiro"
9
+ spec.name = 'chihiro'
8
10
  spec.version = Chihiro::VERSION
9
- spec.authors = ["Shu Hui"]
10
- spec.email = ["dreamlock0630@gmail.com"]
11
+ spec.authors = ['Shu Hui']
12
+ spec.email = ['dreamlock0630@gmail.com']
11
13
 
12
- spec.summary = "Tool for rails log format"
13
- spec.description = "Change rails log to Json format"
14
- spec.homepage = "https://github.com/blockchaintech-au/chihiro"
15
- spec.license = "MIT"
14
+ spec.summary = 'Tool for rails log format'
15
+ spec.description = 'Change rails log to Json format'
16
+ spec.homepage = 'https://github.com/blockchaintech-au/chihiro'
17
+ spec.license = 'MIT'
16
18
 
17
- spec.files = Dir["**/*"].keep_if { |file| File.file?(file) }
18
- spec.require_paths = ["lib"]
19
+ spec.files = Dir['**/*'].keep_if { |file| File.file?(file) }
20
+ spec.require_paths = ['lib']
19
21
 
20
- spec.add_dependency "lograge", "~> 0.10"
22
+ spec.add_dependency 'lograge', '~> 0.10'
21
23
 
22
- spec.add_development_dependency "bundler", "~> 1.16"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec", "~> 3.0"
24
+ spec.add_development_dependency 'bundler', '~> 1.16'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
25
27
  end
@@ -1,13 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Chihiro
2
4
  class Initializer
3
5
  def execute
6
+ setup_log_configuration if ENV['RAILS_ENV'] == 'production'
7
+ end
8
+
9
+ private
10
+
11
+ def setup_log_configuration # rubocop:disable Metrics/MethodLength
4
12
  Rails.application.configure do
5
13
  config.log_formatter = Chihiro::JsonLogFormatter.new
6
14
  config.colorize_logging = false
7
15
  config.lograge.enabled = true
8
- config.lograge.base_controller_class = "ActionController::API"
9
- config.lograge.ignore_actions = ["HealthCheckController#index"]
10
- if ENV["RAILS_LOG_TO_STDOUT"].present?
16
+ config.lograge.base_controller_class = 'ActionController::API'
17
+ config.lograge.ignore_actions = ['HealthCheckController#index']
18
+ if ENV['RAILS_LOG_TO_STDOUT'].present?
11
19
  logger = ActiveSupport::Logger.new(STDOUT)
12
20
  logger.formatter = config.log_formatter
13
21
  config.logger = logger
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Chihiro
3
4
  class JsonLogFormatter < Logger::Formatter
4
5
  def call(severity, _time, _progname, msg)
5
6
  extra_log_data(msg).merge(
6
- "level": severity.downcase,
7
- "project": ENV["PROJECT"],
8
- "environment": ENV["RAILS_ENV"],
9
- "application": ENV["APP_NAME"],
10
- "dateTime": Time.now,
7
+ level: severity.downcase,
8
+ project: ENV['PROJECT'],
9
+ environment: ENV['ENVIRONMENT'],
10
+ application: ENV['APP_NAME'],
11
+ datetime: Time.now
11
12
  ).to_json + "\r\n"
12
13
  end
13
14
 
@@ -17,9 +18,9 @@ module Chihiro
17
18
  if msg.is_a? Hash
18
19
  msg
19
20
  elsif msg.is_a? Exception
20
- {"message": msg.message, "backtrace": msg.backtrace}
21
+ { message: msg.message, backtrace: msg.backtrace }
21
22
  else
22
- {"message": msg}
23
+ { message: msg }
23
24
  end
24
25
  end
25
26
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Chihiro
2
- VERSION = "0.1.7"
4
+ VERSION = '0.1.8'
3
5
  end
data/lib/chihiro.rb CHANGED
@@ -1,6 +1,8 @@
1
- require "chihiro/version"
2
- require "chihiro/initializer"
3
- require "chihiro/json_log_formatter"
1
+ # frozen_string_literal: true
2
+
3
+ require 'chihiro/version'
4
+ require 'chihiro/initializer'
5
+ require 'chihiro/json_log_formatter'
4
6
 
5
7
  module Chihiro
6
8
  # Your code goes here...
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Chihiro
4
4
  class InitGenerator < Rails::Generators::Base
5
- source_root File.expand_path("templates", __dir__)
6
- desc "Generate totoro config file"
5
+ source_root File.expand_path('templates', __dir__)
6
+ desc 'Generate totoro config file'
7
7
 
8
8
  def copy_config_file
9
- template "initializer.rb", File.join("config/initializers", "chihiro.rb")
9
+ template 'initializer.rb', File.join('config/initializers', 'chihiro.rb')
10
10
  end
11
11
  end
12
12
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Chihiro::Initializer.new.execute
Binary file
data/spec/chihiro_spec.rb CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Chihiro do
2
- it "has a version number" do
4
+ it 'has a version number' do
3
5
  expect(Chihiro::VERSION).not_to be nil
4
6
  end
5
7
 
6
- it "does something useful" do
8
+ it 'does something useful' do
7
9
  expect(false).to eq(true)
8
10
  end
9
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chihiro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shu Hui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-24 00:00:00.000000000 Z
11
+ date: 2018-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lograge
@@ -87,13 +87,7 @@ files:
87
87
  - lib/chihiro/version.rb
88
88
  - lib/generators/chihiro/init_generator.rb
89
89
  - lib/generators/chihiro/templates/initializer.rb
90
- - pkg/chihiro-0.1.0.gem
91
- - pkg/chihiro-0.1.1.gem
92
- - pkg/chihiro-0.1.2.gem
93
- - pkg/chihiro-0.1.3.gem
94
- - pkg/chihiro-0.1.4.gem
95
- - pkg/chihiro-0.1.5.gem
96
- - pkg/chihiro-0.1.6.gem
90
+ - pkg/chihiro-0.1.8.gem
97
91
  - spec/chihiro_spec.rb
98
92
  - spec/spec_helper.rb
99
93
  homepage: https://github.com/blockchaintech-au/chihiro
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file