RTALogger 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79dce21ae1cfe72961d564f9e750e49db0adcd564885293e971d482b1df6bf87
4
- data.tar.gz: 44e1d3ae6c92779f6b69677a103c3614f4b2c03429a917c4f61c801b9ab43574
3
+ metadata.gz: 7e81de465e520fd877b0a8be28723ca3df6edc4770a06811cd1321a47a9fe009
4
+ data.tar.gz: ee63b302ec830dcc25cab746f2b5adb6071b2677c1ed4d07884b933946b3e7ca
5
5
  SHA512:
6
- metadata.gz: 78bcdaa73b75e68da879c9f60fe9f3c0b0f9d914269572dc53fbaa3e02d5f1ecf56c35af42b33794675f3b4299f8a247f83aba846e1e9e2bbea18853a277b81d
7
- data.tar.gz: 46b518ac6a9a2df21fd44cfffe3a4ca23e5c6aaba425d8bf5945efb9f590c5a92e945aac407488410f37a897ffb00f42dd0a0d90758eb15495bbab5811ff9bcc
6
+ metadata.gz: 527aead929bac69790be99d22b5d5e0232c96908f8c7935fb9877a2561b2b4cea82bb3ac4cd5b0f869b677e202d52e6b0bddd3bb845a2154b45436729fd3a9ad
7
+ data.tar.gz: be339710ef0c3cf2dd045e165062a058ba3b8a509777522f519505888255f051e5994cb8c2929d17797c06d7b8475d7f08b5e37d2c9d6d5ce48155b067c54ba7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- RTALogger (2.2.2)
4
+ RTALogger (2.3.0)
5
5
  fluent-logger (~> 0.9)
6
6
  jbuilder (~> 2.10)
7
7
 
@@ -1,3 +1,3 @@
1
1
  module RTALogger
2
- VERSION = '2.2.2'.freeze
2
+ VERSION = '2.3.0'.freeze
3
3
  end
@@ -9,7 +9,7 @@ module RTALogger
9
9
  begin
10
10
  load lib_file
11
11
  rescue
12
- raise "unable to load formatter class file: #{lib_file}"
12
+ raise "unable to load filter class file: #{lib_file}"
13
13
  end
14
14
 
15
15
  filter_class_name = 'RTALogger::' + ('log_filter_' + type.to_s).split('_').map(&:capitalize).join
@@ -3,11 +3,14 @@ module RTALogger
3
3
  def initialize
4
4
  @title = self.class.to_s.split('::').last.underscore
5
5
  @enable = true
6
+ @action = :accept
6
7
  end
7
8
 
8
9
  attr_accessor :title
9
10
  attr_accessor :enable
10
11
  attr_accessor :default_regex
12
+ # possible values: accept, ignore
13
+ attr_accessor :action
11
14
 
12
15
  def match_conditions(log_record)
13
16
  return true if !@enable
@@ -18,11 +21,13 @@ module RTALogger
18
21
  @title = config_json['title'] if config_json['title'].present?
19
22
  @enable = config_json['enable'].nil? ? true : config_json['enable'].present?
20
23
  @default_regex = config_json['default_regex'] if config_json['default_regex'].present?
24
+ @action = valid_action(config_json['action']) if config_json['action'].present?
21
25
  end
22
26
 
23
27
  def apply_run_time_config(config_json)
24
28
  @enable = config_json['enable'].nil? ? true : config_json['enable'].present?
25
29
  @default_regex = config_json['default_regex'] if config_json['default_regex'].present?
30
+ @action = valid_action(config_json['action']) if config_json['action'].present?
26
31
  end
27
32
 
28
33
  def to_builder
@@ -35,5 +40,18 @@ module RTALogger
35
40
 
36
41
  jb
37
42
  end
43
+
44
+ private
45
+
46
+ def valid_action(action_value)
47
+ case action_value.to_s.downcase
48
+ when 'accept'
49
+ :accept
50
+ when 'ignore'
51
+ :ignore
52
+ else
53
+ :accept
54
+ end
55
+ end
38
56
  end
39
57
  end
@@ -7,7 +7,9 @@ module RTALogger
7
7
  result = super
8
8
  return result unless result
9
9
 
10
- return default_regex.present? ? (Regexp.new(@default_regex).match(log_record.context_id.to_s)) : result
10
+ result = default_regex.present? ? (Regexp.new(@default_regex).match(log_record.context_id.to_s)) : result
11
+ result = !result if @action == :ignore
12
+ return result
11
13
  end
12
14
  end
13
15
  end
@@ -7,7 +7,9 @@ module RTALogger
7
7
  result = super
8
8
  return result unless result
9
9
 
10
- return default_regex.present? ? (Regexp.new(@default_regex).match(log_record.full_message)) : result
10
+ result = default_regex.present? ? (Regexp.new(@default_regex).match(log_record.full_message)) : result
11
+ result = !result if @action == :ignore
12
+ return result
11
13
  end
12
14
  end
13
15
  end
@@ -7,7 +7,9 @@ module RTALogger
7
7
  result = super
8
8
  return result unless result
9
9
 
10
- return default_regex.present? ? (Regexp.new(@default_regex).match(log_record.topic_title)) : result
10
+ result = default_regex.present? ? (Regexp.new(@default_regex).match(log_record.topic_title)) : result
11
+ result = !result if @action == :ignore
12
+ return result
11
13
  end
12
14
  end
13
15
  end
@@ -71,6 +71,7 @@ module RTALogger
71
71
  config_json = load_config_from_json_file(file_name, title)
72
72
  @config_file_name = file_name if config_json
73
73
  apply_config(config_json)
74
+ self
74
75
  rescue StandardError => e
75
76
  @propagator.drop_all_repositories
76
77
  @propagator.add_log_repository(LogFactory.create_repository(:console))
@@ -79,6 +80,7 @@ module RTALogger
79
80
  def config_use_json_string(config_string, title = '')
80
81
  config_json = load_config_from_json_string(config_string, title)
81
82
  apply_config(config_json)
83
+ self
82
84
  rescue StandardError => e
83
85
  @propagator.drop_all_repositories
84
86
  @propagator.add_log_repository(LogFactory.create_repository(:console))
@@ -27,12 +27,14 @@
27
27
  [
28
28
  {
29
29
  "type": "topic",
30
+ "action" : "ignore",
30
31
  "title": "topic_filter_1",
31
32
  "enable": false,
32
- "default_regex" : "^test$"
33
+ "default_regex" : "^test$",
33
34
  },
34
35
  {
35
36
  "type": "message",
37
+ "action" : "accept",
36
38
  "title": "message_filter_1",
37
39
  "enable": false,
38
40
  "default_regex" : "error"
@@ -53,9 +55,9 @@
53
55
  }
54
56
  },
55
57
  {
56
- "enable": false,
57
58
  "title": "fluentd_repo_1",
58
59
  "type": "fluentd",
60
+ "enable": false,
59
61
  "host": "localhost",
60
62
  "port": "8888",
61
63
  "formatter":
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RTALogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Babak Bahreini, RTA Backend Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-29 00:00:00.000000000 Z
11
+ date: 2021-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluent-logger