eivo-rails-api 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6eb8fb502dfece3bbee217a7ad9b0cc1ec3addf89006a76cf5b0dc95cd4512b2
4
- data.tar.gz: 2708e0777b8c6ff61c316c204a5008c2640d7a98f43b99427af2a22dcc728216
3
+ metadata.gz: c6a6c56a63023bb7746f46774e14d75283fa0eb4a45f5734dfa285fd1a231e16
4
+ data.tar.gz: 367398cf54e3b7a6c0f67cd9042d7209671a8da145358a38c6d5289b395066d3
5
5
  SHA512:
6
- metadata.gz: 707f5dc1d2a49d3b82ad1a35788275302cad5da6295200dbe3d8e06bfae37acd5586db50fbb371b085d8d701a9831a91217e9f6cafee02dc1e1b11ab0c6cb308
7
- data.tar.gz: 193ed57465548b16a7876ac1bdc5f34dbf816d26fb5c41c0b0ac63329cf212246a1ae9d13a0e75e0f7853cb9e7df410b6c2baaa52301e1ff3c0ff13f2fd858bb
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
@@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'eivo-rails-api'
7
- spec.version = '0.1.4'
7
+ spec.version = '0.1.5'
8
8
  spec.authors = ['Jonathan VUKOVICH-TRIBOUHARET']
9
9
  spec.email = ['jonathan@eivo.co']
10
10
 
@@ -9,6 +9,7 @@ require 'fast_jsonapi'
9
9
  require 'kaminari'
10
10
 
11
11
  require_relative 'eivo-rails-api/engine'
12
+ require_relative 'eivo-rails-api/formatter'
12
13
 
13
14
  module EIVO
14
15
  class << self
@@ -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.logger = ActiveSupport::TaggedLogging.new(logger)
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 !ENV['RAILS_DAEMONIZE'].nil?
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
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-04-21 00:00:00.000000000 Z
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.0.6
222
+ rubygems_version: 3.1.2
221
223
  signing_key:
222
224
  specification_version: 4
223
225
  summary: EIVO Rails API