eivo-rails-api 0.1.4 → 0.1.5
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 +4 -4
- data/config/initializers/logger.rb +33 -0
- data/eivo-rails-api.gemspec +1 -1
- data/lib/eivo-rails-api.rb +1 -0
- data/lib/eivo-rails-api/environments/production.rb +8 -2
- data/lib/eivo-rails-api/formatter.rb +31 -0
- data/lib/generators/eivo/templates/config/puma.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6a6c56a63023bb7746f46774e14d75283fa0eb4a45f5734dfa285fd1a231e16
|
4
|
+
data.tar.gz: 367398cf54e3b7a6c0f67cd9042d7209671a8da145358a38c6d5289b395066d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68de242f152c42c5a6fc780124da07c393fce0f6f4ccea5a8c692dfe92706a6c90b3b8d36b7510808e42ed041961376024fe1a7f46a9694f6b653c2719df559c
|
7
|
+
data.tar.gz: 39018bb898894a3da7ea7d13e7abc4b21f75d49c0b56cf0c4787163e388d52fe6866baa3393f1586aa57dcc163506a23bc6d580255819ffc6a5e368395fc5671
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if Rails.env.staging? || Rails.env.production?
|
4
|
+
Rails.application.configure do
|
5
|
+
config.colorize_logging = false
|
6
|
+
|
7
|
+
config.lograge.enabled = true
|
8
|
+
config.lograge.formatter = ::Lograge::Formatters::Raw.new
|
9
|
+
config.lograge.base_controller_class = [
|
10
|
+
'ActionController::API',
|
11
|
+
'ActionController::Base'
|
12
|
+
]
|
13
|
+
|
14
|
+
config.lograge.ignore_actions = ['EIVO::StatusController#index']
|
15
|
+
|
16
|
+
config.lograge.custom_options = ->(event) do
|
17
|
+
result = {
|
18
|
+
params: event.payload[:params].except('controller', 'action', 'format'),
|
19
|
+
request_id: event.payload[:request_id]
|
20
|
+
}
|
21
|
+
|
22
|
+
result[:user_id] = event.payload[:user_id] if event.payload[:user_id]
|
23
|
+
result[:organization_id] = event.payload[:organization_id] if event.payload[:organization_id]
|
24
|
+
|
25
|
+
# https://github.com/roidrage/lograge/pull/307
|
26
|
+
if event.respond_to?(:allocations)
|
27
|
+
result[:allocations] = event.allocations
|
28
|
+
end
|
29
|
+
|
30
|
+
result
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/eivo-rails-api.gemspec
CHANGED
data/lib/eivo-rails-api.rb
CHANGED
@@ -65,9 +65,15 @@ module EIVO
|
|
65
65
|
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
66
66
|
|
67
67
|
if ENV['RAILS_LOG_TO_STDOUT'].present?
|
68
|
-
logger = ActiveSupport::Logger.new(STDOUT)
|
68
|
+
# logger = ActiveSupport::Logger.new(STDOUT)
|
69
|
+
# logger.formatter = config.log_formatter
|
70
|
+
# config.logger = ActiveSupport::TaggedLogging.new(logger)
|
71
|
+
|
72
|
+
config.log_formatter = ::EIVO::Formatter.new
|
73
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
69
74
|
logger.formatter = config.log_formatter
|
70
|
-
config.
|
75
|
+
config.log_level = :info
|
76
|
+
config.logger = logger
|
71
77
|
end
|
72
78
|
|
73
79
|
# Do not dump schema after migrations.
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
require 'multi_json'
|
5
|
+
|
6
|
+
module EIVO
|
7
|
+
class Formatter < ::Logger::Formatter
|
8
|
+
def call(severity, timestamp, progname, message)
|
9
|
+
json = {
|
10
|
+
pid: $PROCESS_ID,
|
11
|
+
level: severity,
|
12
|
+
timestamp: timestamp.utc.iso8601(3),
|
13
|
+
message: message
|
14
|
+
}
|
15
|
+
|
16
|
+
if progname
|
17
|
+
json[:tag] = progname
|
18
|
+
end
|
19
|
+
|
20
|
+
if defined?(::Sidekiq)
|
21
|
+
context = ::Sidekiq::Context.current
|
22
|
+
|
23
|
+
if !context.empty?
|
24
|
+
json[:context] = context
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
MultiJson.dump(json) << "\n"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -9,7 +9,7 @@ environment ENV.fetch('RAILS_ENV') { 'development' }
|
|
9
9
|
if %w[production staging].include?(ENV['RAILS_ENV'])
|
10
10
|
pidfile 'tmp/pids/puma.pid'
|
11
11
|
state_path 'tmp/pids/puma.state'
|
12
|
-
daemonize
|
12
|
+
daemonize ENV.fetch('RAILS_DAEMONIZE') { false }
|
13
13
|
|
14
14
|
if ENV['PORT']
|
15
15
|
bind "tcp://0.0.0.0:#{ENV['PORT']}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eivo-rails-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan VUKOVICH-TRIBOUHARET
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- app/controllers/eivo/concerns/resources.rb
|
173
173
|
- app/controllers/eivo/status_controller.rb
|
174
174
|
- bin/eivo
|
175
|
+
- config/initializers/logger.rb
|
175
176
|
- config/initializers/sentry.rb
|
176
177
|
- config/routes.rb
|
177
178
|
- eivo-rails-api.gemspec
|
@@ -182,6 +183,7 @@ files:
|
|
182
183
|
- lib/eivo-rails-api/environments/production.rb
|
183
184
|
- lib/eivo-rails-api/environments/staging.rb
|
184
185
|
- lib/eivo-rails-api/environments/test.rb
|
186
|
+
- lib/eivo-rails-api/formatter.rb
|
185
187
|
- lib/generators/eivo/USAGE
|
186
188
|
- lib/generators/eivo/install_generator.rb
|
187
189
|
- lib/generators/eivo/templates/.env.example
|
@@ -217,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
219
|
- !ruby/object:Gem::Version
|
218
220
|
version: '0'
|
219
221
|
requirements: []
|
220
|
-
rubygems_version: 3.
|
222
|
+
rubygems_version: 3.1.2
|
221
223
|
signing_key:
|
222
224
|
specification_version: 4
|
223
225
|
summary: EIVO Rails API
|