eivo-rails 0.1.5 → 0.1.6

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: 0d93be1c8da20b7729ec41134ade25b95a6d0a54f984cc66ad8db8cbd0321636
4
- data.tar.gz: e52aa09657baa44657f6ef5998257c148095c4abae7c3ee4117a89d3d01d9248
3
+ metadata.gz: 1f0386c9f9fe278bc745d9e74be0b3480e2e68d6d0161adfd577c2b9891f9056
4
+ data.tar.gz: 817921eba9e490f829b27e43de6961ff4efc8382c7103f09231b197e414063b4
5
5
  SHA512:
6
- metadata.gz: b76321ca09416e19f5acfba35cb45cac14b135c4d9263fd08e13f450b0585386de69962a1374bcdaa3ce4a25c127f759759ac329dc762d7c3e8260000bc2611f
7
- data.tar.gz: 65b34ef15f79f938f5d03051e0207c2ca5c953c60d5a355eab3cc05dd3139b7025a3ccde5aa68e21f5dbf0e27a21a9576a542d298705a14c637da4d8893e98cc
6
+ metadata.gz: efc2b1ae579523dc8097c26822d70f7683a0663d20b81a7c6dae7f9883b73d1b2ea749efaff1ced76997e45f56a39239fe7dce7e62caba46d9dc59ccda855c33
7
+ data.tar.gz: 7d3588ff9a17f4d5ebbeb5dd56d248cff203e3ed6f1ee2027eee43ad9fd748c26986feca4d3cb694a4a238ed324d9294ea3efc1cb84cf0e67cb5f918d8a14d4f
@@ -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.gemspec CHANGED
@@ -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'
7
- spec.version = '0.1.5'
7
+ spec.version = '0.1.6'
8
8
  spec.authors = ['Jonathan VUKOVICH-TRIBOUHARET']
9
9
  spec.email = ['jonathan@eivo.co']
10
10
 
@@ -72,9 +72,15 @@ module EIVO
72
72
  # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
73
73
 
74
74
  if ENV['RAILS_LOG_TO_STDOUT'].present?
75
- logger = ActiveSupport::Logger.new(STDOUT)
75
+ # logger = ActiveSupport::Logger.new(STDOUT)
76
+ # logger.formatter = config.log_formatter
77
+ # config.logger = ActiveSupport::TaggedLogging.new(logger)
78
+
79
+ config.log_formatter = ::EIVO::Formatter.new
80
+ logger = ActiveSupport::Logger.new(STDOUT)
76
81
  logger.formatter = config.log_formatter
77
- config.logger = ActiveSupport::TaggedLogging.new(logger)
82
+ config.log_level = :info
83
+ config.logger = logger
78
84
  end
79
85
 
80
86
  # 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
data/lib/eivo-rails.rb CHANGED
@@ -6,6 +6,7 @@ require 'oj'
6
6
  require 'multi_json'
7
7
 
8
8
  require_relative 'eivo-rails/engine'
9
+ require_relative 'eivo-rails/formatter'
9
10
 
10
11
  module EIVO
11
12
  class << self
@@ -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
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
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
@@ -142,6 +142,7 @@ files:
142
142
  - app/controllers/eivo/concerns/resources.rb
143
143
  - app/controllers/eivo/status_controller.rb
144
144
  - bin/eivo
145
+ - config/initializers/logger.rb
145
146
  - config/initializers/sentry.rb
146
147
  - config/routes.rb
147
148
  - eivo-rails.gemspec
@@ -152,6 +153,7 @@ files:
152
153
  - lib/eivo-rails/environments/production.rb
153
154
  - lib/eivo-rails/environments/staging.rb
154
155
  - lib/eivo-rails/environments/test.rb
156
+ - lib/eivo-rails/formatter.rb
155
157
  - lib/generators/eivo/USAGE
156
158
  - lib/generators/eivo/install_generator.rb
157
159
  - lib/generators/eivo/templates/.env.example
@@ -187,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
189
  - !ruby/object:Gem::Version
188
190
  version: '0'
189
191
  requirements: []
190
- rubygems_version: 3.0.6
192
+ rubygems_version: 3.1.2
191
193
  signing_key:
192
194
  specification_version: 4
193
195
  summary: EIVO Rails