chihiro 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -2
- data/README.md +4 -12
- data/Rakefile +5 -3
- data/chihiro.gemspec +17 -15
- data/lib/chihiro/initializer.rb +11 -3
- data/lib/chihiro/json_log_formatter.rb +8 -7
- data/lib/chihiro/version.rb +3 -1
- data/lib/chihiro.rb +5 -3
- data/lib/generators/chihiro/init_generator.rb +3 -3
- data/lib/generators/chihiro/templates/initializer.rb +2 -0
- data/pkg/chihiro-0.1.8.gem +0 -0
- data/spec/chihiro_spec.rb +4 -2
- metadata +3 -9
- data/pkg/chihiro-0.1.0.gem +0 -0
- data/pkg/chihiro-0.1.1.gem +0 -0
- data/pkg/chihiro-0.1.2.gem +0 -0
- data/pkg/chihiro-0.1.3.gem +0 -0
- data/pkg/chihiro-0.1.4.gem +0 -0
- data/pkg/chihiro-0.1.5.gem +0 -0
- data/pkg/chihiro-0.1.6.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b02e72d647ea1919e47c783bf04a46a4a239b0e7d22d97723491e4be03d06ec8
|
4
|
+
data.tar.gz: b59dcbe80d7d1f2363cd85db1c4179bd79a3b63175ea2ed103cbf593bc835a28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b19306ae9f799370cd051693d0435aea38fc79479843a610a472963a205e382f4d088a9e6b6bf745c8dcc164065c2a20c5e9536675f75ebed13f2e4a7471bfb2
|
7
|
+
data.tar.gz: 2b737de4c58abce1d4b34d16803a28b7c1db88dc784e3667228f853f8019cb7f67ce92e14d1d5a226d6be5e205fc1a6667a91d0dd969b77c44c86a23987a95ce
|
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
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
|
-
|
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
|
-
##
|
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
|
-
|
23
|
+
add `Chihiro::Initializer.new.execute` to your `application.rb`
|
32
24
|
|
33
25
|
## Contributing
|
34
26
|
|
data/Rakefile
CHANGED
data/chihiro.gemspec
CHANGED
@@ -1,25 +1,27 @@
|
|
1
1
|
|
2
|
-
|
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
|
6
|
+
require 'chihiro/version'
|
5
7
|
|
6
8
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
9
|
+
spec.name = 'chihiro'
|
8
10
|
spec.version = Chihiro::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
+
spec.authors = ['Shu Hui']
|
12
|
+
spec.email = ['dreamlock0630@gmail.com']
|
11
13
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
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[
|
18
|
-
spec.require_paths = [
|
19
|
+
spec.files = Dir['**/*'].keep_if { |file| File.file?(file) }
|
20
|
+
spec.require_paths = ['lib']
|
19
21
|
|
20
|
-
spec.add_dependency
|
22
|
+
spec.add_dependency 'lograge', '~> 0.10'
|
21
23
|
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
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
|
data/lib/chihiro/initializer.rb
CHANGED
@@ -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 =
|
9
|
-
config.lograge.ignore_actions = [
|
10
|
-
if ENV[
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
{
|
21
|
+
{ message: msg.message, backtrace: msg.backtrace }
|
21
22
|
else
|
22
|
-
{
|
23
|
+
{ message: msg }
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
data/lib/chihiro/version.rb
CHANGED
data/lib/chihiro.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
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(
|
6
|
-
desc
|
5
|
+
source_root File.expand_path('templates', __dir__)
|
6
|
+
desc 'Generate totoro config file'
|
7
7
|
|
8
8
|
def copy_config_file
|
9
|
-
template
|
9
|
+
template 'initializer.rb', File.join('config/initializers', 'chihiro.rb')
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
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
|
4
|
+
it 'has a version number' do
|
3
5
|
expect(Chihiro::VERSION).not_to be nil
|
4
6
|
end
|
5
7
|
|
6
|
-
it
|
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.
|
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-
|
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.
|
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
|
data/pkg/chihiro-0.1.0.gem
DELETED
Binary file
|
data/pkg/chihiro-0.1.1.gem
DELETED
Binary file
|
data/pkg/chihiro-0.1.2.gem
DELETED
Binary file
|
data/pkg/chihiro-0.1.3.gem
DELETED
Binary file
|
data/pkg/chihiro-0.1.4.gem
DELETED
Binary file
|
data/pkg/chihiro-0.1.5.gem
DELETED
Binary file
|
data/pkg/chihiro-0.1.6.gem
DELETED
Binary file
|