log_toolbox 1.3.2 → 1.3.3

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: 57fc2307fa88005cade48e4ca2ec7d7eb2fc160f96df2200ee8da7e87d721620
4
- data.tar.gz: cbcffcc9ff47fe85c034eb3dcf41c8e025e14ef0b259138ab31e1a1ca746ef87
3
+ metadata.gz: 24e688450de60928e21dffc4f149fad36b8fdcccbc99c66a7490f8a7c120f26e
4
+ data.tar.gz: 906faf4de7058fd15a773dfd1e329642a912e09c4c7b7a7cebdf7d69f395be87
5
5
  SHA512:
6
- metadata.gz: e6a625722e73a5d4497f75917180af29cf35539038b914223d33c2db9ba26fbcc39e246a2fcaaad48f0a8343efd52b41fbc96cd73c0f019c7a141bcce3b9299e
7
- data.tar.gz: c02133b3f39b44d36b791408f53e25bfae822d99446de414b4e213ad5edbc8976a87859a7bf67ab982099bf9699846be5f3eac54add3c01dbfb0d3bfadc849d8
6
+ metadata.gz: 3306c7347f81a106a9d591c56462b9cd63edde7247a6c66ae0137eebda42dcb0db491e37415e71cf917248c1a7f2a389eb423642d9bf820bd809f590ce0ecbbb
7
+ data.tar.gz: d4aeec51d7a437a6124b64d15ed502cea87ec9f52780abc9f9959cd884e2a52724040104a130668c1d170c10831bd95d6b3243841fb22365d17e8d9fc71afff8
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Released] - 2019-05-21
8
8
 
9
+ ## [1.3.3] - 2020-11-25
10
+ ### Added
11
+ - Parametrize logstash protocol
12
+ - Refactor request logs
13
+
9
14
  ## [1.3.2] - 2020-02-19
10
15
  ### Fixed
11
16
  - Fixed log simple sending to logstash
@@ -1,11 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- log_toolbox (1.3.0)
4
+ log_toolbox (1.3.3)
5
5
  lograge (>= 0.11.1)
6
6
  logstash-event (>= 1.2.02)
7
7
  logstash-logger (>= 0.26.1)
8
8
  rails (>= 4.0)
9
+ rspec (>= 3.0.0)
10
+ rspec-rails
9
11
 
10
12
  GEM
11
13
  remote: https://rubygems.org/
@@ -81,11 +83,11 @@ GEM
81
83
  marcel (0.3.3)
82
84
  mimemagic (~> 0.3.2)
83
85
  method_source (0.9.2)
84
- mimemagic (0.3.3)
86
+ mimemagic (0.3.5)
85
87
  mini_mime (1.0.2)
86
88
  mini_portile2 (2.4.0)
87
89
  minitest (5.11.3)
88
- nio4r (2.4.0)
90
+ nio4r (2.5.4)
89
91
  nokogiri (1.10.3)
90
92
  mini_portile2 (~> 2.4.0)
91
93
  parallel (1.17.0)
@@ -126,8 +128,12 @@ GEM
126
128
  thor (>= 0.19.0, < 2.0)
127
129
  rainbow (3.0.0)
128
130
  rake (12.3.2)
129
- request_store (1.4.1)
131
+ request_store (1.5.0)
130
132
  rack (>= 1.4)
133
+ rspec (3.8.0)
134
+ rspec-core (~> 3.8.0)
135
+ rspec-expectations (~> 3.8.0)
136
+ rspec-mocks (~> 3.8.0)
131
137
  rspec-core (3.8.2)
132
138
  rspec-support (~> 3.8.0)
133
139
  rspec-expectations (3.8.4)
@@ -155,10 +161,10 @@ GEM
155
161
  ruby-progressbar (1.10.1)
156
162
  shoulda-matchers (3.1.3)
157
163
  activesupport (>= 4.0.0)
158
- sprockets (3.7.2)
164
+ sprockets (4.0.2)
159
165
  concurrent-ruby (~> 1.0)
160
166
  rack (> 1, < 3)
161
- sprockets-rails (3.2.1)
167
+ sprockets-rails (3.2.2)
162
168
  actionpack (>= 4.0)
163
169
  activesupport (>= 4.0)
164
170
  sprockets (>= 3.0.0)
@@ -168,9 +174,9 @@ GEM
168
174
  tzinfo (1.2.5)
169
175
  thread_safe (~> 0.1)
170
176
  unicode-display_width (1.6.0)
171
- websocket-driver (0.7.1)
177
+ websocket-driver (0.7.3)
172
178
  websocket-extensions (>= 0.1.0)
173
- websocket-extensions (0.1.4)
179
+ websocket-extensions (0.1.5)
174
180
 
175
181
  PLATFORMS
176
182
  ruby
@@ -8,7 +8,7 @@ pipelines:
8
8
  - gem update bundler
9
9
  - bundle install
10
10
  - gem install rubocop
11
- - rspec -fdoc
11
+ - bundle exec rspec -fdoc
12
12
  - rubocop .
13
13
 
14
14
  branches:
@@ -7,7 +7,7 @@ module LogToolbox
7
7
  'fatal',
8
8
  additional.merge(
9
9
  message: error.try(:message),
10
- exception_stack: error.try(:backtrace),
10
+ backtrace: error.try(:backtrace),
11
11
  status: 500
12
12
  )
13
13
  )
@@ -31,7 +31,7 @@ module LogToolbox
31
31
 
32
32
  private
33
33
 
34
- # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
34
+ # rubocop:disable Metrics/MethodLength
35
35
  def default_log(level)
36
36
  level = 'CRITICAL' if level == 'FATAL'
37
37
  {
@@ -45,7 +45,7 @@ module LogToolbox
45
45
  username: request.headers['Authorization']
46
46
  }
47
47
  end
48
- # rubocop:enable Metrics/AbcSize,Metrics/MethodLength
48
+ # rubocop:enable Metrics/MethodLength
49
49
 
50
50
  def log_pattern(level, log_hash)
51
51
  log = default_log(level.upcase).merge(log_hash)
@@ -12,7 +12,7 @@ module LogToolbox
12
12
  def append_info_to_payload(payload)
13
13
  super
14
14
  payload[:activityID] = request.headers['activityID']
15
- payload[:event_at] = I18n.l(Time.now, format: :timestamp)
15
+ payload[:event_at] = I18n.l(Time.current, format: :timestamp)
16
16
  payload[:service_name] = LogUtil.system_service_name
17
17
  payload[:version] = LogUtil.system_version
18
18
  payload[:origin_ipv4] = request.env['REMOTE_ADDR']
@@ -7,6 +7,10 @@ module LogToolbox
7
7
  class LogrageConfig
8
8
  attr_accessor :config
9
9
 
10
+ LOGSTASH_URL = ENV['LOGSTASH_URL']
11
+ LOGSTASH_PORT = ENV['LOGSTASH_PORT']
12
+ LOGSTASH_PROTOCOL = ENV.fetch('LOGSTASH_PROTOCOL', 'udp')
13
+
10
14
  def self.configure
11
15
  Rails.application.configure do
12
16
  log_config = LogToolbox::LogrageConfig.new(config)
@@ -24,15 +28,15 @@ module LogToolbox
24
28
  end
25
29
 
26
30
  def configure_log_output_logstash
27
- config.logger = LogStashLogger.new(type: :udp,
28
- host: ENV['LOGSTASH_URL'],
29
- port: ENV['LOGSTASH_PORT'])
31
+ config.logger = LogStashLogger.new(type: LOGSTASH_PROTOCOL,
32
+ host: LOGSTASH_URL,
33
+ port: LOGSTASH_PORT)
30
34
  end
31
35
 
32
36
  def configure_log_output_stdout
33
37
  return unless ENV['RAILS_LOG_TO_STDOUT'].present?
34
38
 
35
- logger = ActiveSupport::Logger.new(STDOUT)
39
+ logger = ActiveSupport::Logger.new($stdout)
36
40
  logger.formatter = config.log_formatter
37
41
  config.logger = ActiveSupport::TaggedLogging.new(logger)
38
42
  end
@@ -45,19 +49,23 @@ module LogToolbox
45
49
 
46
50
  config.lograge.custom_options = lambda do |event|
47
51
  {
48
- activityID: event.payload[:activityID],
49
52
  event_at: event.payload[:event_at],
53
+ parameters: event.payload[:params].to_json,
50
54
  level: 'INFO',
51
55
  service_name: event.payload[:service_name],
52
56
  version: event.payload[:version],
53
57
  origin_ipv4: event.payload[:origin_ipv4],
54
58
  destination_ipv4: event.payload[:destination_ipv4],
55
- username: event.payload[:username],
56
- exception_stack: event.payload[:exception_stack],
57
- response: event.payload[:response]
59
+ username: wso2_user_name(event.payload[:headers][:HTTP_USER_IDENTIFIER])
58
60
  }
59
61
  end
60
62
  end
61
63
  # rubocop:enable Metrics/AbcSize,Metrics/MethodLength
64
+
65
+ def wso2_user_name(http_user_identifier)
66
+ return nil unless http_user_identifier.is_a? String
67
+
68
+ http_user_identifier ? JSON.parse(Base64.decode64(http_user_identifier))['user_name'] : nil
69
+ end
62
70
  end
63
71
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LogToolbox
4
- VERSION = '1.3.2'
4
+ VERSION = '1.3.3'
5
5
  end
@@ -4,17 +4,19 @@ lib = File.expand_path('lib', __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'log_toolbox/version'
6
6
 
7
+ # rubocop:disable Metrics/BlockLength
7
8
  Gem::Specification.new do |spec|
8
- spec.name = 'log_toolbox'
9
- spec.version = LogToolbox::VERSION
10
- spec.authors = ['Caio Almeida']
11
- spec.email = ['cbalmeida@guide.com.br']
9
+ spec.name = 'log_toolbox'
10
+ spec.version = LogToolbox::VERSION
11
+ spec.authors = ['Caio Almeida']
12
+ spec.email = ['cbalmeida@guide.com.br']
12
13
 
13
- spec.summary = 'Guide default gem for ruby application logging'
14
- spec.homepage = 'http://bitbucket.org/guideinvestimentos/log_toolbox'
15
- spec.license = 'Guide'
14
+ spec.required_ruby_version = '>= 2.4.0'
15
+ spec.summary = 'Guide default gem for ruby application logging'
16
+ spec.homepage = 'http://bitbucket.org/guideinvestimentos/log_toolbox'
17
+ spec.license = 'Guide'
16
18
 
17
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
20
  `git ls-files -z`.split("\x0").reject do |f|
19
21
  f.match(%r{^(test|spec|features)/})
20
22
  end
@@ -36,3 +38,4 @@ Gem::Specification.new do |spec|
36
38
  spec.add_development_dependency 'rubocop'
37
39
  spec.add_development_dependency 'shoulda-matchers', '~> 3.1'
38
40
  end
41
+ # rubocop:enable Metrics/BlockLength
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caio Almeida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-19 00:00:00.000000000 Z
11
+ date: 2020-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lograge
@@ -234,7 +234,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
234
234
  requirements:
235
235
  - - ">="
236
236
  - !ruby/object:Gem::Version
237
- version: '0'
237
+ version: 2.4.0
238
238
  required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  requirements:
240
240
  - - ">="