chili_logger 0.0.1 → 0.0.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: 10b5fc2b3c38931ea3e011926d0b53bde8c815afa458355551141c4e0848c210
4
- data.tar.gz: ba11f3e2061537c5ac53b2082154678c534409ee6114b6e7eabbd538231db8e6
3
+ metadata.gz: cd18a0767d4bd7b2bcfb3ab126b667b3d0696d50937b895c555ff3d5a1e9e064
4
+ data.tar.gz: e4bf5de02cb00478f256b8f72c4d91198ba31f06e3b100ece8b3a8b3f0ea5db4
5
5
  SHA512:
6
- metadata.gz: b89430120e833f374bcd1e5e4613184f450228ba787d7e0a0bd0a4ae7932bd73cdaac480bc06a8b5b3a594c9f6721b5ef27ab6911e625441b7c3d90cf13ec499
7
- data.tar.gz: 4498034a82c5ced13a1a342e0dc449ebf6872806a50544eaa85ecc4d251f7d3c85e097b1e528d6ff850f4fbe806b5481342f2cb23de3be0f57cd170006ab8fe9
6
+ metadata.gz: c7f4297ed8ae37aa9c5288a97df7dfbf4fccb2fefc3088bde8b3b73598625da57bdca91024d8452ddfe0b5d77e73356bef4f369b0c087cbe4b2497360ea40c24
7
+ data.tar.gz: 407653271688b085a8aa73af94ec54dd87885ff81d4261d7a5de8c65d29d08341e37f0443da5a37d599e3ad88901d4b01bfd60c62394cf6364c03fa0a2ba0f24
@@ -1,4 +1,14 @@
1
1
  continue
2
+ e.class
3
+ e.is_a?(Bunny:TCPConnectionFailed)
4
+ e
5
+ @sqs.send_message('queue_message')
6
+ @sqs.get_queue_url(queue_name: 'mockeesd').queue_url
7
+ @sqs.get_queue_url(queue_name: 'mock').queue_url
8
+ @sqs.get_queue_url(queue_name: queue_name).queue_url
9
+ @sqs
10
+ response
11
+ continue
2
12
  cloud_metadata[@cloud_provider]
3
13
  @cloud_provider
4
14
  continue
data/.gitignore CHANGED
@@ -7,5 +7,7 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
+ local_tests_cheatsheet.rb
11
+
10
12
  # rspec failure tracking
11
13
  .rspec_status
data/Gemfile CHANGED
@@ -3,11 +3,12 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in chili_logger.gemspec
4
4
  gemspec
5
5
 
6
- gem "activerecord", "~> 5.2"
6
+ gem 'activerecord', '~> 5.2'
7
+ gem 'aws-sdk', '2.9.2'
7
8
  gem 'bunny'
8
9
  gem 'byebug'
9
10
  gem 'rake', '~> 12.0'
10
11
  gem 'rspec', '~> 3.0'
11
12
  gem 'rubocop', '~> 0.60.0', require: false
12
13
 
13
- gem "httparty", "~> 0.18.1"
14
+ gem 'httparty', '~> 0.18.1'
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chili_logger (0.0.0)
5
- bunny
6
- httparty
4
+ chili_logger (0.0.3)
5
+ aws-sdk (~> 2.9.2)
6
+ bunny (~> 2.15.0)
7
+ httparty (~> 0.18.1)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
@@ -21,29 +22,40 @@ GEM
21
22
  tzinfo (~> 1.1)
22
23
  amq-protocol (2.3.1)
23
24
  arel (9.0.0)
24
- ast (2.4.0)
25
+ ast (2.4.1)
26
+ aws-eventstream (1.1.0)
27
+ aws-sdk (2.9.2)
28
+ aws-sdk-resources (= 2.9.2)
29
+ aws-sdk-core (2.9.2)
30
+ aws-sigv4 (~> 1.0)
31
+ jmespath (~> 1.0)
32
+ aws-sdk-resources (2.9.2)
33
+ aws-sdk-core (= 2.9.2)
34
+ aws-sigv4 (1.1.4)
35
+ aws-eventstream (~> 1.0, >= 1.0.2)
25
36
  bunny (2.15.0)
26
37
  amq-protocol (~> 2.3, >= 2.3.1)
27
38
  byebug (11.0.1)
28
39
  concurrent-ruby (1.1.6)
29
- diff-lcs (1.3)
40
+ diff-lcs (1.4.2)
30
41
  httparty (0.18.1)
31
42
  mime-types (~> 3.0)
32
43
  multi_xml (>= 0.5.2)
33
44
  i18n (1.8.3)
34
45
  concurrent-ruby (~> 1.0)
35
46
  jaro_winkler (1.5.4)
47
+ jmespath (1.4.0)
36
48
  mime-types (3.3.1)
37
49
  mime-types-data (~> 3.2015)
38
50
  mime-types-data (3.2020.0512)
39
51
  minitest (5.14.1)
40
52
  multi_xml (0.6.0)
41
- parallel (1.19.1)
42
- parser (2.7.1.3)
43
- ast (~> 2.4.0)
53
+ parallel (1.19.2)
54
+ parser (2.7.1.4)
55
+ ast (~> 2.4.1)
44
56
  powerpack (0.1.2)
45
57
  rainbow (3.0.0)
46
- rake (12.3.1)
58
+ rake (12.3.3)
47
59
  rspec (3.9.0)
48
60
  rspec-core (~> 3.9.0)
49
61
  rspec-expectations (~> 3.9.0)
@@ -76,6 +88,7 @@ PLATFORMS
76
88
 
77
89
  DEPENDENCIES
78
90
  activerecord (~> 5.2)
91
+ aws-sdk (= 2.9.2)
79
92
  bunny
80
93
  byebug
81
94
  chili_logger!
@@ -85,4 +98,4 @@ DEPENDENCIES
85
98
  rubocop (~> 0.60.0)
86
99
 
87
100
  BUNDLED WITH
88
- 2.1.4
101
+ 1.17.3
Binary file
@@ -11,8 +11,9 @@ Gem::Specification.new do |spec|
11
11
  spec.homepage = 'https://gitlab.com/chiligumdev/chili_logger'
12
12
  spec.license = 'MIT'
13
13
  spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
14
- spec.add_dependency 'bunny'
15
- spec.add_dependency 'httparty'
14
+ spec.add_dependency 'aws-sdk', '~> 2.9.2'
15
+ spec.add_dependency 'bunny', '~> 2.15.0'
16
+ spec.add_dependency 'httparty', '~> 0.18.1'
16
17
 
17
18
  # Specify which files should be added to the gem when it is released.
18
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -1,10 +1,15 @@
1
1
  require 'bunny'
2
- require 'errors/rabbitmq_error'
2
+ require 'errors/error_messages/rabbitmq_error'
3
+ require 'errors/logging_error_handler/logging_error_handler'
3
4
 
4
5
  # class for centralizing Creative's logging logic
5
6
  class ChiliLogger
6
7
  # class that configures and manages the RabbitMQ client
7
8
  class RabbitBroker
9
+ def initialize(logging_error_handler)
10
+ @logging_error_handler = logging_error_handler
11
+ end
12
+
8
13
  def config(config)
9
14
  validate_config(config)
10
15
 
@@ -13,7 +18,7 @@ class ChiliLogger
13
18
  @ip = config[:ip]
14
19
  @port = config[:port]
15
20
  @exchange_name = config[:exchange_name]
16
- @routing_key = config[:routing_key]
21
+ @routing_key_overwriter = config[:routing_key]
17
22
 
18
23
  connect
19
24
  end
@@ -21,15 +26,15 @@ class ChiliLogger
21
26
  def connect
22
27
  return if ChiliLogger.instance.deactivated
23
28
 
24
- @connection = Bunny.new("amqp://#{@user}:#{@password}@#{@ip}:#{@port}")
29
+ @connection = Bunny.new(connection_config)
25
30
  @connection.start
26
31
 
27
32
  @channel = @connection.create_channel
28
33
  @exchange = @channel.topic(@exchange_name, durable: true)
29
34
 
30
- # wraps errors in a ChiliLogger class, so it's easier for user to see that the problem happened in chili_logger gem
31
- rescue Bunny::Exception => e
32
- raise(ChiliLogger::RabbitMQError, e.message)
35
+ rescue StandardError => e
36
+ puts 'Could not connect to RabbitMQ due to the following error:'
37
+ puts e
33
38
  end
34
39
 
35
40
  def disconnect
@@ -40,21 +45,38 @@ class ChiliLogger
40
45
  return if ChiliLogger.instance.deactivated
41
46
 
42
47
  # if no routing_key was provided when configuring RabbitBroker, than use the one received by the method here
43
- # temporary solution so we can test, while we don't implement correct routing_keys in logstash/elasticsearch
44
- key = @routing_key || routing_key
48
+ # temporary solution so we can force configure ChiliLogger to use a specific routing_key
49
+ key = @routing_key_overwriter || routing_key
45
50
  @exchange.publish(message.to_json, routing_key: key)
51
+
52
+ rescue StandardError => e
53
+ @logging_error_handler.handle_error(e, message)
46
54
  end
47
55
 
48
56
  private
49
57
 
50
58
  def invalid_config_format_error
51
- 'The configuration object must include a Hash'
59
+ 'The configuration object must be a Hash'
52
60
  end
53
61
 
54
62
  def config_attr_error(attr)
55
63
  "The configuration object must include a ':#{attr}' attribute"
56
64
  end
57
65
 
66
+ def connection_config
67
+ # shouldn't try to recover connection,
68
+ # it may cause app in production to collapse if reconnection doesn't work or takes too many attempts!!!
69
+ recovery_attempts = 0
70
+
71
+ {
72
+ user: @user,
73
+ password: @password,
74
+ host: @ip,
75
+ port: @port,
76
+ recovery_attempts: recovery_attempts
77
+ }
78
+ end
79
+
58
80
  def validate_config(config)
59
81
  raise(ChiliLogger::ConfigError, invalid_config_format_error) unless config.is_a?(Hash)
60
82
 
@@ -1,8 +1,9 @@
1
1
  require 'chili_logger/version'
2
2
  require 'current_log_accessor'
3
- require 'errors/config_error'
3
+ require 'errors/error_messages/config_error'
4
4
  require 'brokers/rabbit_broker'
5
5
  require 'message_writer/message_writer'
6
+ require 'errors/logging_error_handler/logging_error_handler'
6
7
  require 'singleton'
7
8
 
8
9
  # class for centralizing Creative's logging logic
@@ -16,6 +17,7 @@ class ChiliLogger
16
17
  def config(config)
17
18
  @deactivated = config[:deactivated] || false # ChilLogger can be deactivated for test environents
18
19
 
20
+ config_logging_error_handler(config)
19
21
  config_msg_writer(config)
20
22
  config_msg_broker(config)
21
23
 
@@ -45,6 +47,14 @@ class ChiliLogger
45
47
 
46
48
  private
47
49
 
50
+ def config_logging_error_handler(general_config)
51
+ return @logging_error_handler = nil if @deactivated
52
+
53
+ error_handler_name = general_config[:error_handler]
54
+ handler_config = general_config[:error_handler_config]
55
+ @logging_error_handler = LoggingErrorHandler.new(error_handler_name, handler_config)
56
+ end
57
+
48
58
  def config_msg_writer(general_config)
49
59
  msg_writer_config = {
50
60
  env: general_config[:log_env],
@@ -56,12 +66,17 @@ class ChiliLogger
56
66
  @msg_writer = MessageWriter.new(msg_writer_config)
57
67
  end
58
68
 
59
- def config_msg_broker(config)
60
- msg_broker_name = config[:msg_broker_name] || :rabbitmq
61
- msg_broker_config = config[:msg_broker_config] || {}
69
+ def config_msg_broker(general_config)
70
+ msg_broker_name = general_config[:msg_broker_name] || :rabbitmq
71
+ msg_broker_config = general_config[:msg_broker_config] || {}
62
72
  @msg_broker = supported_msg_brokers[msg_broker_name.to_sym]
63
73
  raise(ConfigError, broker_name_error(msg_broker_name)) unless @msg_broker
64
74
 
75
+ # TODO: implement MessageBroker class, an interface between ChiliLogger and possible brokers.
76
+ # TODO: add "supported_msg_broker", "broker_name_error" and "return @msg_broker if @deactivated" to MessageBroker
77
+ # prevents broker from even starting connection if ChiliLogger is deactivated
78
+ return @msg_broker if @deactivated
79
+
65
80
  @msg_broker.config(msg_broker_config)
66
81
  end
67
82
 
@@ -71,7 +86,7 @@ class ChiliLogger
71
86
 
72
87
  def supported_msg_brokers
73
88
  {
74
- rabbitmq: RabbitBroker.new
89
+ rabbitmq: RabbitBroker.new(@logging_error_handler)
75
90
  }
76
91
  end
77
92
  end
@@ -1,3 +1,3 @@
1
1
  class ChiliLogger
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -0,0 +1,37 @@
1
+ require 'errors/logging_error_handler/sqs_handler'
2
+ require 'errors/error_messages/config_error'
3
+
4
+ # class for centralizing Creative's logging logic
5
+ class ChiliLogger
6
+ # class that handles errors when message broker can't be reached, etc...
7
+ class LoggingErrorHandler
8
+ def initialize(name, config)
9
+ raise(ChiliLogger::ConfigError, ':error_handler_config must be present and be a hash') unless config.is_a?(Hash)
10
+
11
+ name = name.to_sym if name
12
+ error_handler_class = supported_error_handlers[name]
13
+ unsupported_handler_error unless error_handler_class
14
+
15
+ @error_handler = error_handler_class.new(config)
16
+ end
17
+
18
+ def handle_error(error, log = nil)
19
+ @error_handler.handle_error(error, log)
20
+ end
21
+
22
+ private
23
+
24
+ def unsupported_handler_error
25
+ error_handlers = supported_error_handlers.keys.join(', ')
26
+ unsupported_err = ":error_handler must be present and have one of the following values: #{error_handlers}"
27
+
28
+ raise(ChiliLogger::ConfigError, unsupported_err)
29
+ end
30
+
31
+ def supported_error_handlers
32
+ {
33
+ aws_sqs: AWS::SqsHandler
34
+ }
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,71 @@
1
+ require 'aws-sdk'
2
+ require 'errors/error_messages/rabbitmq_error'
3
+
4
+ # class for centralizing Creative's logging logic
5
+ class ChiliLogger
6
+ # module with classes using Amazon Web Services services
7
+ module AWS
8
+ # class that handles errors when message broker can't be reached, etc...
9
+ class SqsHandler
10
+ def initialize(config)
11
+ @sqs_config = validate_config(config)
12
+ @queue_name = config[:queue_name]
13
+
14
+ @sqs = Aws::SQS::Client.new(@sqs_config)
15
+ end
16
+
17
+ def handle_error(error = StandardError.new, log = 'not_specified')
18
+ message_body = message_body(error, log)
19
+ queue_message = queue_message(message_body)
20
+
21
+ @sqs.send_message(queue_message)
22
+ end
23
+
24
+ private
25
+
26
+ def queue_message(message_body)
27
+ {
28
+ queue_url: queue_url(@queue_name),
29
+ message_body: message_body.to_json,
30
+ message_group_id: SecureRandom.hex(8).to_s,
31
+ message_deduplication_id: SecureRandom.hex(8).to_s
32
+ }
33
+ end
34
+
35
+ def message_body(error, log)
36
+ message_body = {
37
+ error_type: error.class.name,
38
+ error_message: error.message,
39
+ log: log
40
+ }
41
+
42
+ { body: message_body }
43
+ end
44
+
45
+ def queue_url(queue_name)
46
+ @sqs.get_queue_url(queue_name: queue_name).queue_url
47
+ end
48
+
49
+ def invalid_config_format_error
50
+ 'The :error_hanldler_config object must be a Hash'
51
+ end
52
+
53
+ def config_attr_error(attr)
54
+ "The configuration object must include a ':#{attr}' attribute"
55
+ end
56
+
57
+ def validate_config(config)
58
+ raise(ChiliLogger::ConfigError, invalid_config_format_error) unless config.is_a?(Hash)
59
+
60
+ main_config_keys = %i[region access_key_id secret_access_key queue_name]
61
+ main_config_keys.each { |key| raise(ChiliLogger::ConfigError, config_attr_error(key)) unless config[key] }
62
+
63
+ {
64
+ region: config[:region],
65
+ access_key_id: config[:access_key_id],
66
+ secret_access_key: config[:secret_access_key]
67
+ }
68
+ end
69
+ end
70
+ end
71
+ end
@@ -1,6 +1,5 @@
1
1
  require 'httparty'
2
2
  require 'logs_coverage/coverage_writer'
3
- require 'helpers/rails_backtrace_cleaner'
4
3
  require 'message_writer/aws_ops_metadata'
5
4
 
6
5
  # class for centralizing Creative's logging logic
@@ -1,5 +1,4 @@
1
1
  require 'logs_coverage/coverage_writer'
2
- require 'helpers/rails_backtrace_cleaner'
3
2
  require 'message_writer/aws_ops_metadata'
4
3
 
5
4
  # class for centralizing Creative's logging logic
@@ -11,7 +10,6 @@ class ChiliLogger
11
10
  @layer = config[:layer] || 'not_specified'
12
11
  @server_url = config[:server_url] || 'not_specified'
13
12
  @cloud_provider = config[:cloud_provider]
14
- @backtrace_cleaner = RailsBacktraceCleaner.new
15
13
  end
16
14
 
17
15
  def write(desc = {}, agent = 'not_specified', main_content = {})
@@ -20,11 +18,16 @@ class ChiliLogger
20
18
  desc ||= {}
21
19
  main_content ||= {}
22
20
 
23
- main_content.merge!({ backtrace: @backtrace_cleaner.clean(caller) })
21
+ main_content.merge!( backtrace: clean_backtrace(caller) )
24
22
  update_logs_coverage(desc, main_content)
25
23
  message_hash(desc, agent, main_content)
26
24
  end
27
25
 
26
+ def clean_backtrace(backtrace)
27
+ backtrace.reject! { |line| line =~ %r{bundle\/gems} }
28
+ backtrace
29
+ end
30
+
28
31
  def write_description_tag(desc)
29
32
  env = desc[:env] || @env
30
33
  layer = desc[:layer] || @layer
@@ -39,7 +42,7 @@ class ChiliLogger
39
42
 
40
43
  # uses message infos to keep logs_coverage up to date with what logs are being generated in the application
41
44
  def update_logs_coverage(desc, main_content)
42
- backtrace = main_content[:backtrace] || @backtrace_cleaner.clean(caller)
45
+ backtrace = main_content[:backtrace] || clean_backtrace(caller)
43
46
  CoverageWriter.write(desc, backtrace)
44
47
  end
45
48
 
@@ -64,15 +67,18 @@ class ChiliLogger
64
67
  return unless @cloud_provider
65
68
 
66
69
  provider = @cloud_provider.is_a?(String) ? @cloud_provider.to_sym : @cloud_provider
70
+ cloud_ops_metadata = cloud_metadata[provider]
71
+ return unless cloud_ops_metadata
72
+
67
73
  {
68
74
  server_url: @server_url,
69
- cloud: cloud_metadata[provider]
75
+ cloud: cloud_ops_metadata.write
70
76
  }
71
77
  end
72
78
 
73
79
  def cloud_metadata
74
80
  {
75
- aws: AwsOpsMetadata.write
81
+ aws: AwsOpsMetadata
76
82
  }
77
83
  end
78
84
  end
@@ -0,0 +1,50 @@
1
+ ---
2
+ test:
3
+ console:
4
+ publish_test:
5
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/chili_logger-0.0.2/lib/chili_logger.rb:42:in
6
+ `publish_instant_log'"
7
+ - "(pry):28:in `__pry__'"
8
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/pry_instance.rb:290:in
9
+ `eval'"
10
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/pry_instance.rb:290:in
11
+ `evaluate_ruby'"
12
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/pry_instance.rb:659:in
13
+ `handle_line'"
14
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/pry_instance.rb:261:in
15
+ `block (2 levels) in eval'"
16
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/pry_instance.rb:260:in
17
+ `catch'"
18
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/pry_instance.rb:260:in
19
+ `block in eval'"
20
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/pry_instance.rb:259:in
21
+ `catch'"
22
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/pry_instance.rb:259:in
23
+ `eval'"
24
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/repl.rb:77:in `block
25
+ in repl'"
26
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/repl.rb:67:in `loop'"
27
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/repl.rb:67:in `repl'"
28
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/repl.rb:38:in `block
29
+ in start'"
30
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/input_lock.rb:61:in
31
+ `__with_ownership'"
32
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/input_lock.rb:78:in
33
+ `with_ownership'"
34
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/repl.rb:38:in `start'"
35
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/repl.rb:15:in `start'"
36
+ - "/home/lucas/.rvm/gems/ruby-2.3.3/gems/pry-0.13.1/lib/pry/pry_class.rb:191:in
37
+ `start'"
38
+ - "/home/lucas/.irbrc:8:in `<top (required)>'"
39
+ - "/usr/share/rvm/scripts/irbrc.rb:40:in `load'"
40
+ - "/usr/share/rvm/scripts/irbrc.rb:40:in `<top (required)>'"
41
+ - "/usr/share/rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in
42
+ `require'"
43
+ - "/usr/share/rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in
44
+ `require'"
45
+ - "/usr/share/rvm/rubies/ruby-2.3.3/.irbrc:11:in `<top (required)>'"
46
+ - "/usr/share/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/irb/init.rb:231:in `load'"
47
+ - "/usr/share/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/irb/init.rb:231:in `run_config'"
48
+ - "/usr/share/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/irb/init.rb:20:in `setup'"
49
+ - "/usr/share/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/irb.rb:378:in `start'"
50
+ - "/usr/share/rvm/rubies/ruby-2.3.3/bin/irb:11:in `<main>'"
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chili_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - lucas sandeville
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-27 00:00:00.000000000 Z
11
+ date: 2020-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.9.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.9.2
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bunny
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - ">="
31
+ - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '0'
33
+ version: 2.15.0
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - ">="
38
+ - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '0'
40
+ version: 2.15.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: httparty
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - ">="
45
+ - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '0'
47
+ version: 0.18.1
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ">="
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '0'
54
+ version: 0.18.1
41
55
  description: placeholder
42
56
  email:
43
57
  - lucas.sandeville@gmail.com
@@ -57,19 +71,22 @@ files:
57
71
  - Rakefile
58
72
  - bin/console
59
73
  - bin/setup
74
+ - chili_logger-0.0.1.gem
60
75
  - chili_logger.gemspec
61
76
  - lib/brokers/rabbit_broker.rb
62
77
  - lib/chili_logger.rb
63
78
  - lib/chili_logger/version.rb
64
79
  - lib/current_log_accessor.rb
65
- - lib/errors/config_error.rb
66
- - lib/errors/rabbitmq_error.rb
67
- - lib/helpers/rails_backtrace_cleaner.rb
80
+ - lib/errors/error_messages/config_error.rb
81
+ - lib/errors/error_messages/rabbitmq_error.rb
82
+ - lib/errors/logging_error_handler/logging_error_handler.rb
83
+ - lib/errors/logging_error_handler/sqs_handler.rb
68
84
  - lib/logs_coverage/chili_logger_coverage.yml
69
85
  - lib/logs_coverage/coverage_writer.rb
70
86
  - lib/logs_coverage/levantamento_provisório.yaml
71
87
  - lib/message_writer/aws_ops_metadata.rb
72
88
  - lib/message_writer/message_writer.rb
89
+ - log/chili-logger-coverage.yml
73
90
  homepage: https://gitlab.com/chiligumdev/chili_logger
74
91
  licenses:
75
92
  - MIT
@@ -1,130 +0,0 @@
1
- # Backtraces often include many lines that are not relevant for the context
2
- # under review. This makes it hard to find the signal amongst the backtrace
3
- # noise, and adds debugging time. With a BacktraceCleaner, filters and
4
- # silencers are used to remove the noisy lines, so that only the most relevant
5
- # lines remain.
6
- #
7
- # Filters are used to modify lines of data, while silencers are used to remove
8
- # lines entirely. The typical filter use case is to remove lengthy path
9
- # information from the start of each line, and view file paths relevant to the
10
- # app directory instead of the file system root. The typical silencer use case
11
- # is to exclude the output of a noisy library from the backtrace, so that you
12
- # can focus on the rest.
13
- #
14
- # bc = ActiveSupport::BacktraceCleaner.new
15
- # bc.add_filter { |line| line.gsub(Rails.root.to_s, '') } # strip the Rails.root prefix
16
- # bc.add_silencer { |line| line =~ /puma|rubygems/ } # skip any lines from puma or rubygems
17
- # bc.clean(exception.backtrace) # perform the cleanup
18
- #
19
- # To reconfigure an existing BacktraceCleaner (like the default one in Rails)
20
- # and show as much data as possible, you can always call
21
- # <tt>BacktraceCleaner#remove_silencers!</tt>, which will restore the
22
- # backtrace to a pristine state. If you need to reconfigure an existing
23
- # BacktraceCleaner so that it does not filter or modify the paths of any lines
24
- # of the backtrace, you can call <tt>BacktraceCleaner#remove_filters!</tt>
25
- # These two methods will give you a completely untouched backtrace.
26
-
27
- # BacktraceCleaner from Rails, copied ipsis literis
28
- # github: https://github.com/rails/rails/blob/fbe2433be6e052a1acac63c7faf287c52ed3c5ba/activesupport/lib/active_support/backtrace_cleaner.rb#L41
29
- class RailsBacktraceCleaner
30
- def initialize
31
- @filters = []
32
- @silencers = []
33
- add_gem_filter
34
- add_gem_silencer
35
- add_stdlib_silencer
36
- end
37
-
38
- # Returns the backtrace after all filters and silencers have been run
39
- # against it. Filters run first, then silencers.
40
- def clean(backtrace, kind = :silent)
41
- filtered = filter_backtrace(backtrace)
42
-
43
- case kind
44
- when :silent
45
- silence(filtered)
46
- when :noise
47
- noise(filtered)
48
- else
49
- filtered
50
- end
51
- end
52
- alias filter clean
53
-
54
- # Adds a filter from the block provided. Each line in the backtrace will be
55
- # mapped against this filter.
56
- #
57
- # # Will turn "/my/rails/root/app/models/person.rb" into "/app/models/person.rb"
58
- # backtrace_cleaner.add_filter { |line| line.gsub(Rails.root, '') }
59
- def add_filter(&block)
60
- @filters << block
61
- end
62
-
63
- # Adds a silencer from the block provided. If the silencer returns +true+
64
- # for a given line, it will be excluded from the clean backtrace.
65
- #
66
- # # Will reject all lines that include the word "puma", like "/gems/puma/server.rb" or "/app/my_puma_server/rb"
67
- # backtrace_cleaner.add_silencer { |line| line =~ /puma/ }
68
- def add_silencer(&block)
69
- @silencers << block
70
- end
71
-
72
- # Removes all silencers, but leaves in the filters. Useful if your
73
- # context of debugging suddenly expands as you suspect a bug in one of
74
- # the libraries you use.
75
- def remove_silencers!
76
- @silencers = []
77
- end
78
-
79
- # Removes all filters, but leaves in the silencers. Useful if you suddenly
80
- # need to see entire filepaths in the backtrace that you had already
81
- # filtered out.
82
- def remove_filters!
83
- @filters = []
84
- end
85
-
86
- private
87
-
88
- FORMATTED_GEMS_PATTERN = %r{/\A[^\/]+ \([\w.]+\) /}.freeze
89
-
90
- def add_gem_filter
91
- gems_paths = (Gem.path | [Gem.default_dir]).map { |p| Regexp.escape(p) }
92
- return if gems_paths.empty?
93
-
94
- gems_regexp = %r{(#{gems_paths.join('|')})/(bundler/)?gems/([^/]+)-([\w.]+)/(.*)}
95
- gems_result = '\3 (\4) \5'
96
- add_filter { |line| line.sub(gems_regexp, gems_result) }
97
- end
98
-
99
- def add_gem_silencer
100
- add_silencer { |line| FORMATTED_GEMS_PATTERN.match(line).nil? }
101
- end
102
-
103
- def add_stdlib_silencer
104
- add_silencer { |line| line.start_with?(RbConfig::CONFIG['rubylibdir']) }
105
- end
106
-
107
- def filter_backtrace(backtrace)
108
- @filters.each do |f|
109
- backtrace = backtrace.map { |line| f.call(line) }
110
- end
111
-
112
- backtrace
113
- end
114
-
115
- def silence(backtrace)
116
- @silencers.each do |s|
117
- backtrace = backtrace.reject { |line| s.call(line) }
118
- end
119
-
120
- backtrace
121
- end
122
-
123
- def noise(backtrace)
124
- backtrace.select do |line|
125
- @silencers.any? do |s|
126
- s.call(line)
127
- end
128
- end
129
- end
130
- end