RTALogger 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/RTALogger/version.rb +1 -1
- data/lib/log_factory_filter.rb +1 -1
- data/lib/log_filter_base.rb +18 -0
- data/lib/log_filter_context.rb +3 -1
- data/lib/log_filter_message.rb +3 -1
- data/lib/log_filter_topic.rb +3 -1
- data/lib/log_manager.rb +2 -0
- data/lib/rta_logger_config.json +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e81de465e520fd877b0a8be28723ca3df6edc4770a06811cd1321a47a9fe009
|
4
|
+
data.tar.gz: ee63b302ec830dcc25cab746f2b5adb6071b2677c1ed4d07884b933946b3e7ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 527aead929bac69790be99d22b5d5e0232c96908f8c7935fb9877a2561b2b4cea82bb3ac4cd5b0f869b677e202d52e6b0bddd3bb845a2154b45436729fd3a9ad
|
7
|
+
data.tar.gz: be339710ef0c3cf2dd045e165062a058ba3b8a509777522f519505888255f051e5994cb8c2929d17797c06d7b8475d7f08b5e37d2c9d6d5ce48155b067c54ba7
|
data/Gemfile.lock
CHANGED
data/lib/RTALogger/version.rb
CHANGED
data/lib/log_factory_filter.rb
CHANGED
@@ -9,7 +9,7 @@ module RTALogger
|
|
9
9
|
begin
|
10
10
|
load lib_file
|
11
11
|
rescue
|
12
|
-
raise "unable to load
|
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
|
data/lib/log_filter_base.rb
CHANGED
@@ -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
|
data/lib/log_filter_context.rb
CHANGED
@@ -7,7 +7,9 @@ module RTALogger
|
|
7
7
|
result = super
|
8
8
|
return result unless result
|
9
9
|
|
10
|
-
|
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
|
data/lib/log_filter_message.rb
CHANGED
@@ -7,7 +7,9 @@ module RTALogger
|
|
7
7
|
result = super
|
8
8
|
return result unless result
|
9
9
|
|
10
|
-
|
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
|
data/lib/log_filter_topic.rb
CHANGED
@@ -7,7 +7,9 @@ module RTALogger
|
|
7
7
|
result = super
|
8
8
|
return result unless result
|
9
9
|
|
10
|
-
|
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
|
data/lib/log_manager.rb
CHANGED
@@ -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))
|
data/lib/rta_logger_config.json
CHANGED
@@ -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.
|
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:
|
11
|
+
date: 2021-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluent-logger
|