log_toolbox 1.3.2 → 1.3.7

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: 63f24d53b86979a1060c9a087c3c65b94c7f25bd6f4303edc63199e79580e2ba
4
+ data.tar.gz: cacbfcf42a486458d6c949b2dbd2829baaf6d46a5e3b2873ec74cbd430a4424a
5
5
  SHA512:
6
- metadata.gz: e6a625722e73a5d4497f75917180af29cf35539038b914223d33c2db9ba26fbcc39e246a2fcaaad48f0a8343efd52b41fbc96cd73c0f019c7a141bcce3b9299e
7
- data.tar.gz: c02133b3f39b44d36b791408f53e25bfae822d99446de414b4e213ad5edbc8976a87859a7bf67ab982099bf9699846be5f3eac54add3c01dbfb0d3bfadc849d8
6
+ metadata.gz: 24d0cb468176260e5ebe240d6f5559efdcc1602f58a43152cacb866c8a29e90cd69b100393b551d106eeb6f0c3f2f52fe4bdee82f11ff674f25b7157f0260c7a
7
+ data.tar.gz: a08c22ec7826cf3860fa08d7f8a63c671146b6f6331cf59a0a1fa1c91a02cbe234402bf94f2bda73d8e511c254e8f8a8654608908de20839fd4131bbe9f24a5e
@@ -6,6 +6,27 @@ 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.7] - 2020-12-04
10
+ ### Added
11
+ - Configure log output stdout to development and test environment
12
+
13
+ ## [1.3.6] - 2020-12-04
14
+ ### FIXED
15
+ - Added buffer_max_items and buffer_max_interval into LogStash config
16
+
17
+ ## [1.3.5] - 2020-12-04
18
+ ### FIXED
19
+ - Convert buffer_max_items and buffer_max_interval values to integer
20
+
21
+ ## [1.3.4] - 2020-12-03
22
+ ### Added
23
+ - Add settings to buffer_max_items and buffer_max_interval
24
+
25
+ ## [1.3.3] - 2020-11-25
26
+ ### Added
27
+ - Parametrize logstash protocol
28
+ - Refactor request logs
29
+
9
30
  ## [1.3.2] - 2020-02-19
10
31
  ### Fixed
11
32
  - 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.5)
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,11 +7,17 @@ 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
+ LOGSTASH_BUFFER_MAX_ITEMS = ENV.fetch('LOGSTASH_BUFFER_MAX_ITEMS', 50).to_i
14
+ LOGSTASH_BUFFER_MAX_INTERVAL = ENV.fetch('LOGSTASH_BUFFER_MAX_INTERVAL', 5).to_i
15
+
10
16
  def self.configure
11
17
  Rails.application.configure do
12
18
  log_config = LogToolbox::LogrageConfig.new(config)
13
19
  log_config.configure_log_format
14
- if ENV['RAILS_ENV'] == 'development'
20
+ if %w[development test].include?(ENV['RAILS_ENV'])
15
21
  log_config.configure_log_output_stdout
16
22
  else
17
23
  log_config.configure_log_output_logstash
@@ -24,15 +30,18 @@ module LogToolbox
24
30
  end
25
31
 
26
32
  def configure_log_output_logstash
27
- config.logger = LogStashLogger.new(type: :udp,
28
- host: ENV['LOGSTASH_URL'],
29
- port: ENV['LOGSTASH_PORT'])
33
+ config.logger = LogStashLogger.new(type: LOGSTASH_PROTOCOL,
34
+ host: LOGSTASH_URL,
35
+ port: LOGSTASH_PORT)
36
+
37
+ config.logstash.buffer_max_items = LOGSTASH_BUFFER_MAX_ITEMS
38
+ config.logstash.buffer_max_interval = LOGSTASH_BUFFER_MAX_INTERVAL
30
39
  end
31
40
 
32
41
  def configure_log_output_stdout
33
42
  return unless ENV['RAILS_LOG_TO_STDOUT'].present?
34
43
 
35
- logger = ActiveSupport::Logger.new(STDOUT)
44
+ logger = ActiveSupport::Logger.new($stdout)
36
45
  logger.formatter = config.log_formatter
37
46
  config.logger = ActiveSupport::TaggedLogging.new(logger)
38
47
  end
@@ -45,19 +54,23 @@ module LogToolbox
45
54
 
46
55
  config.lograge.custom_options = lambda do |event|
47
56
  {
48
- activityID: event.payload[:activityID],
49
57
  event_at: event.payload[:event_at],
58
+ parameters: event.payload[:params].to_json,
50
59
  level: 'INFO',
51
60
  service_name: event.payload[:service_name],
52
61
  version: event.payload[:version],
53
62
  origin_ipv4: event.payload[:origin_ipv4],
54
63
  destination_ipv4: event.payload[:destination_ipv4],
55
- username: event.payload[:username],
56
- exception_stack: event.payload[:exception_stack],
57
- response: event.payload[:response]
64
+ username: wso2_user_name(event.payload[:headers][:HTTP_USER_IDENTIFIER])
58
65
  }
59
66
  end
60
67
  end
61
68
  # rubocop:enable Metrics/AbcSize,Metrics/MethodLength
69
+
70
+ def wso2_user_name(http_user_identifier)
71
+ return nil unless http_user_identifier.is_a? String
72
+
73
+ http_user_identifier ? JSON.parse(Base64.decode64(http_user_identifier))['user_name'] : nil
74
+ end
62
75
  end
63
76
  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.7'
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.5.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.7
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-12-08 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.5.0
238
238
  required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  requirements:
240
240
  - - ">="