RTALogger 0.1.2 → 1.1.1
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/README.md +186 -90
- data/lib/RTALogger/version.rb +1 -1
- data/lib/log_factory_log_formatter.rb +24 -8
- data/lib/log_factory_repository.rb +23 -42
- data/lib/log_factory_topic.rb +2 -2
- data/lib/log_formatter_base.rb +33 -0
- data/lib/log_formatter_json.rb +6 -3
- data/lib/log_formatter_text.rb +11 -8
- data/lib/log_manager.rb +124 -48
- data/lib/log_propagator.rb +17 -15
- data/lib/log_record.rb +1 -1
- data/lib/log_repository.rb +43 -1
- data/lib/log_repository_console.rb +5 -1
- data/lib/log_repository_file.rb +33 -3
- data/lib/log_repository_fluentd.rb +58 -0
- data/lib/log_repository_udp.rb +14 -6
- data/lib/log_topic.rb +24 -14
- data/lib/rta_logger_config.json +43 -22
- data/lib/sample.rb +12 -2
- data/lib/severity_level.rb +60 -0
- data/lib/string.rb +9 -0
- metadata +6 -6
- data/lib/log_factory_file_logger.rb +0 -17
- data/lib/log_formatter.rb +0 -8
- data/lib/log_repository_fluent.rb +0 -32
- data/lib/log_severity.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b037c1dbb6f51228afd43cfc7e576e86a7e46e711b96cedaaeb9a5b3e5f3f1ec
|
4
|
+
data.tar.gz: d1e2fb9ee4cddf0b221b0ec9c471117953387c502337e3d438b82348ce4111ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fe26e02fcdb17eb44f56644469f7061a925f5dfdc25afcde968b1d910eb5f25a13a49e25afeec8898e78eb7398bbcabe53fca3b7ca98dc85afdeae304ba12a0
|
7
|
+
data.tar.gz: 11fdcff4f789f1eb739cd307c9f60c52b7f6a2816caa60699b0d1f607fba0a3cf7619e58dd17d6817b4711ba35f4998585e64a8d0f099142f8c3009210220759
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -6,23 +6,25 @@ Also provide multiple extendable log repositories including wrapping existing lo
|
|
6
6
|
All log manager's main features are configable through a json config file.
|
7
7
|
|
8
8
|
Main purposes of developing this gem are:
|
9
|
-
- Creating
|
10
|
-
-
|
11
|
-
-
|
9
|
+
- Creating standard logging API to seperate application from existing variety of loggers.
|
10
|
+
- Wrapping around existing loggers to get advantage of different loggers at the same time.
|
11
|
+
- Make it possible to easily replace a logger component with new one without any changes in the consumer application.(for example Rails standard Logger with Fluentd)
|
12
|
+
- Creating easy to use logger interface for developers.
|
13
|
+
- Apply some rules and restrictions about log structure and data format, which prevents chaos in application's log information.
|
14
|
+
- No interrupt, wait time or overhead for log consumer modules.
|
12
15
|
- Utilize multiple log repositories at the same time in background (Console, File, UDP, FluentD, etc.)
|
13
|
-
- Make it possible to implement
|
16
|
+
- Make it possible to implement customize log repositories.
|
14
17
|
|
15
18
|
Main Features:
|
16
19
|
- Creating multiple log manager instances with different configuration is possible entire application.
|
17
20
|
- Each log manager instance could be configured via a json file.
|
18
21
|
- Each log manager instance could be config to use multiple log repositories such as Console, File, UDP, Fluentd.
|
19
22
|
- Runtime configurations could be applied through log manager APIs.
|
20
|
-
- By using multi threading
|
21
|
-
all logging process will handled in seperated thread.
|
23
|
+
- By using multi threading and buffering techniques, all logging process will handled in seperated thread.
|
22
24
|
So the log consumer modules should not be wait for log manager to finish the logging task.
|
23
25
|
- Multiple standard log severity levels are available through topic APIs (debug, info, warning, error, fatal, unknown)
|
24
26
|
- Main features could be set and manipulate through json configuration file.
|
25
|
-
- And at the end, it is easy to use for ruby
|
27
|
+
- And at the end, it is easy to use for ruby developers.
|
26
28
|
|
27
29
|
## Installation
|
28
30
|
|
@@ -32,11 +34,11 @@ Add this line to your application's Gemfile:
|
|
32
34
|
gem 'RTALogger'
|
33
35
|
```
|
34
36
|
|
35
|
-
|
37
|
+
Then execute:
|
36
38
|
|
37
39
|
$ bundle install
|
38
40
|
|
39
|
-
Or install it yourself
|
41
|
+
Or install it yourself via following command:
|
40
42
|
|
41
43
|
$ gem install RTALogger
|
42
44
|
|
@@ -47,12 +49,12 @@ To add gem to your rails application:
|
|
47
49
|
## Usage
|
48
50
|
#### RTA Log Data Structure
|
49
51
|
To use log manager APIs, first step is to have a quick review on Log Data Structure
|
50
|
-
- Application: The root of each log data record is Application, which specify the log data owner application.
|
52
|
+
- Application: The root of each log data record is the Application name, which specify the log data owner application.
|
51
53
|
- Topic: By adding multiple topics to log manager you can categorize log data in logical topics.
|
52
54
|
- Context: Under each topic, one or multiple contexts (in one level) could be defined.
|
53
|
-
- As an instance
|
54
|
-
|
55
|
-
- The next step is log severity level, which determines
|
55
|
+
- As an instance for Application 'MyEShopApp', one of Topics could be 'Authentication' and
|
56
|
+
Context could be 'uer_name' which attend in application authorization process.
|
57
|
+
- The next step is log severity level, which determines the log record severity (debug, information, warning, error, fatal, unknown)
|
56
58
|
- At last the final element is log message, which contains log message data.
|
57
59
|
|
58
60
|
### Which Log Severity Levels to use
|
@@ -77,6 +79,51 @@ To use log manager APIs, first step is to have a quick review on Log Data Struct
|
|
77
79
|
# the parameter is the json config file
|
78
80
|
log_manager.config_use_json_file('rta_logger_config.json')
|
79
81
|
```
|
82
|
+
- Sample configuration json file
|
83
|
+
```
|
84
|
+
{
|
85
|
+
"rta_logger":
|
86
|
+
{
|
87
|
+
"default_manager": "develop",
|
88
|
+
"log_managers":
|
89
|
+
[
|
90
|
+
{
|
91
|
+
"manager_name": "develop",
|
92
|
+
"enable": true,
|
93
|
+
"app_name": "TestApp",
|
94
|
+
"severity_level": "debug",
|
95
|
+
"buffer_size": 100,
|
96
|
+
"flush_wait_seconds": 15,
|
97
|
+
"repositories":
|
98
|
+
[
|
99
|
+
{
|
100
|
+
"enable": true,
|
101
|
+
"type": "console",
|
102
|
+
"formatter": "delimited_text",
|
103
|
+
"delimiter": "|"
|
104
|
+
},
|
105
|
+
{
|
106
|
+
"enable": true,
|
107
|
+
"type": "File",
|
108
|
+
"file_path": "./log/log.txt",
|
109
|
+
"roll_period": "daily",
|
110
|
+
"roll_size": "1048576",
|
111
|
+
"formatter": "delimited_text",
|
112
|
+
"delimiter": "|"
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"enable": true,
|
116
|
+
"type": "fluentd",
|
117
|
+
"host": "localhost",
|
118
|
+
"port": "8888",
|
119
|
+
"formatter": "json"
|
120
|
+
}
|
121
|
+
]
|
122
|
+
}
|
123
|
+
]
|
124
|
+
}
|
125
|
+
}
|
126
|
+
```
|
80
127
|
- Add new topic to log manager and get the topic instance
|
81
128
|
```ruby
|
82
129
|
# the parameter is the topic name
|
@@ -98,60 +145,68 @@ To use log manager APIs, first step is to have a quick review on Log Data Struct
|
|
98
145
|
```
|
99
146
|
the result will be:
|
100
147
|
```
|
101
|
-
{"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":
|
102
|
-
{"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":
|
103
|
-
{"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":
|
104
|
-
{"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":
|
105
|
-
{"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":
|
106
|
-
{"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":
|
148
|
+
{"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":"DEBUG","message":"user_id is nil for user: Tom"}
|
149
|
+
{"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":"INFO","message":"User Tom is trying to login"}
|
150
|
+
{"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":"WARN","message":"Authentication failed for user Tom"}
|
151
|
+
{"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":"ERROR","message":"Error connecting to data base for user Tom"}
|
152
|
+
{"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":"FATAL","message":"Authentication service has been stopped working"}
|
153
|
+
{"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":"UNKNOWN","message":"An unknown error occured during authentication. user name: Tom"}
|
107
154
|
```
|
108
155
|
- json config file sample
|
109
156
|
```json
|
110
157
|
{
|
111
|
-
"
|
158
|
+
"rta_logger":
|
112
159
|
{
|
113
|
-
"
|
114
|
-
"
|
160
|
+
"default_manager": "develop",
|
161
|
+
"log_managers":
|
115
162
|
[
|
116
163
|
{
|
117
|
-
"
|
118
|
-
"
|
119
|
-
"
|
120
|
-
"
|
121
|
-
"
|
122
|
-
"
|
123
|
-
"
|
124
|
-
"Repos":
|
164
|
+
"manager_name": "develop",
|
165
|
+
"enable": true,
|
166
|
+
"app_name": "TestApp",
|
167
|
+
"severity_level": "debug",
|
168
|
+
"buffer_size": 100,
|
169
|
+
"flush_wait_seconds": 15,
|
170
|
+
"repositories":
|
125
171
|
[
|
126
172
|
{
|
127
|
-
"
|
128
|
-
"
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
"Port": 8888
|
173
|
+
"enable": true,
|
174
|
+
"type": "console",
|
175
|
+
"formatter":
|
176
|
+
{
|
177
|
+
"type": "text",
|
178
|
+
"delimiter": "|"
|
179
|
+
}
|
135
180
|
},
|
136
181
|
{
|
137
|
-
"
|
138
|
-
"
|
139
|
-
"
|
140
|
-
"
|
141
|
-
"
|
182
|
+
"enable": false,
|
183
|
+
"type": "file",
|
184
|
+
"file_path": "log.txt",
|
185
|
+
"roll_period": "daily",
|
186
|
+
"roll_size": "1048576",
|
187
|
+
"formatter":
|
188
|
+
{
|
189
|
+
"type": "text",
|
190
|
+
"delimiter": "|"
|
191
|
+
}
|
142
192
|
},
|
143
193
|
{
|
144
|
-
"
|
145
|
-
"
|
146
|
-
"
|
147
|
-
"
|
148
|
-
"
|
194
|
+
"enable": false,
|
195
|
+
"type": "fluentd",
|
196
|
+
"host": "localhost",
|
197
|
+
"port": "8888",
|
198
|
+
"formatter":
|
149
199
|
{
|
150
|
-
"
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
200
|
+
"type": "json"
|
201
|
+
}
|
202
|
+
}
|
203
|
+
],
|
204
|
+
"topics":
|
205
|
+
[
|
206
|
+
{
|
207
|
+
"title": "test",
|
208
|
+
"enable": true,
|
209
|
+
"severity_level": "info"
|
155
210
|
}
|
156
211
|
]
|
157
212
|
}
|
@@ -166,47 +221,64 @@ the result will be:
|
|
166
221
|
log_manager.config_use_json_file('rta_logger_config.json')
|
167
222
|
|
168
223
|
The file structure:
|
169
|
-
-
|
170
|
-
-
|
224
|
+
- rta_logger : the root element of rta_logger json configuration.
|
225
|
+
- default_manager: the name of default log manager config, when there is
|
171
226
|
multiple log manager configuration in Log_Managers array.
|
172
|
-
-
|
227
|
+
- log_managers : the array of LogManagers with different configuration.
|
173
228
|
It is possible to define multiple log manager configurations for differen usages.
|
174
|
-
-
|
175
|
-
-
|
176
|
-
-
|
177
|
-
-
|
178
|
-
-
|
229
|
+
- manager_name: the name of log manager. It will be used to define the default log manager.
|
230
|
+
- enable: (true/false) The value of this property activate or deactivate entire log manager.
|
231
|
+
- app_name: Application name as the owner of log data.
|
232
|
+
- severity_level: Defines which level of log data will be stored in log repositories.
|
233
|
+
- buffer_size: Minimune possible value for this attribute is 100 and defines memory buffer size (number of buffered log objects) to
|
179
234
|
decread api consumers wait time. when the buffer is full the flush operation will
|
180
235
|
save buffered logs to log repositoies.
|
181
|
-
-
|
236
|
+
- flush_wait_seconds: Minimum possible value for this attribure is 10 seconds and defines time in soconds which log managers wait to flush buffered log records
|
182
237
|
to log repository.
|
183
|
-
-
|
184
|
-
- Repos: Array of log repositories. It is possible to define multiple log repositories to
|
238
|
+
- repositories: Array of log repositories. It is possible to define multiple log repositories to
|
185
239
|
store log data. there are variaty of log repositories and it is possible to
|
186
240
|
add new ones. Each item in Repos array will configure a log repository.
|
241
|
+
Pre-defined types are described below, also it's possible to implement your custome repo type
|
242
|
+
and register it to RTALogger.
|
187
243
|
- Log repository types and config:
|
188
|
-
1-
|
189
|
-
- "
|
190
|
-
- "
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
- "
|
244
|
+
1- console: Show log data in text format on standard out put
|
245
|
+
- "type": "console"
|
246
|
+
- "enable": [true/false] this will activate or deactivate log repository.
|
247
|
+
- "foramtter" is the text, json or any custome defined types as LogRecord formatter
|
248
|
+
- "type": ["text"/"json"] type of formatter
|
249
|
+
- "delimiter": [any text delimiter you need.(as an instance pipe line "|")]
|
250
|
+
if formatter not defined then the json formatter will be used
|
251
|
+
2- file: Store log data in a file.
|
252
|
+
- "type": "console"
|
253
|
+
- "enable": [true/false] this will activate or deactivate log repository.
|
254
|
+
- "file_path": [file path and file name] the path and the name to store log data.
|
255
|
+
- "roll_period": ["daily"/"weekly"/"monthly"] the period to generate new log file.
|
256
|
+
- "roll_size": [bytes] the maximum size of log file to
|
197
257
|
roll file and create the new log file
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
- "
|
205
|
-
- "
|
206
|
-
- "
|
207
|
-
|
208
|
-
- "
|
209
|
-
|
258
|
+
- "foramtter" is the text, json or any custome defined types as LogRecord formatter
|
259
|
+
- "type": ["text"/"json"] type of formatter
|
260
|
+
- "delimiter": [any text delimiter you need.(as an instance pipe line "|")]
|
261
|
+
if formatter not defined then the json formatter will be used
|
262
|
+
3- udp: Send log data over UDP on network.
|
263
|
+
- "type": "udp"
|
264
|
+
- "enable": [true/false] this will activate or deactivate log repository.
|
265
|
+
- "host": IP of the server to send log data.
|
266
|
+
- "port": Port of server to send log data.
|
267
|
+
4- fluentd: send log data to Fluentd Log collector over network using TCP/IP protocol.
|
268
|
+
- "type": "fluentd"
|
269
|
+
- "enable": [true/false] this will activate or deactivate log repository.
|
270
|
+
- "host": IP of the server to send log data.
|
271
|
+
- "port": Port of server to send log data.
|
272
|
+
- "tls_options": TLS configuration to stablish a secure TCP connection to Fluentd Server.
|
273
|
+
- "foramtter" is the text, json or any custome defined types as LogRecord formatter
|
274
|
+
- "type": ["text"/"json"] type of formatter
|
275
|
+
- "delimiter": [any text delimiter you need.(as an instance pipe line "|")]
|
276
|
+
if formatter not defined then the json formatter will be used
|
277
|
+
- topics: This is an optional item. When you need to customize a specific topic severity level or
|
278
|
+
enable value, you can define the settings here.
|
279
|
+
- title: The topic title to customize. (mandatoy).
|
280
|
+
- severity_level: Defines which level of log data will be stored in log repositories.
|
281
|
+
- enable: [true/false] to enable or disable logging process of the topic.
|
210
282
|
```
|
211
283
|
- Some useful features
|
212
284
|
```ruby
|
@@ -214,14 +286,38 @@ the result will be:
|
|
214
286
|
log_manager.app_name = 'myTestApp'
|
215
287
|
|
216
288
|
# update specific topic log level if necessary
|
217
|
-
log_manager.
|
289
|
+
log_manager.update_topic_severity_level(topic_title, RTALogger::SeverityLevel::INFO)
|
290
|
+
|
291
|
+
# update all topics severity level if necessary
|
292
|
+
log_manager.update_all_topics_severity_level(RTALogger::SeverityLevel::INFO)
|
218
293
|
|
219
|
-
#
|
220
|
-
log_manager.
|
294
|
+
# enable or disable specific topic if necessary
|
295
|
+
log_manager.update_topic_enable(topic_title, [true/false])
|
296
|
+
|
297
|
+
# enable or disable all topic if necessary
|
298
|
+
log_manager.update_all_topics_enable([true/false])
|
221
299
|
```
|
222
300
|
- Implement and Expand
|
223
|
-
It is possible to implement new log repositories.
|
224
|
-
|
301
|
+
It is possible to implement new log repositories. There will be fue rules to implement and
|
302
|
+
integrate new customized log repository with RTALogger LogManager.
|
303
|
+
|
304
|
+
1- Define you class inside RTALogger module.
|
305
|
+
|
306
|
+
2- The class should be inherited from 'RTALogger::LogRepository'.
|
307
|
+
|
308
|
+
3- Also appropriate naming convention is necessary.
|
309
|
+
As an example if you are implementing a Console Repo, your class name should be LogRepositoryConsole and
|
310
|
+
your source code in a ruby file and name it log_repository_console.rb
|
311
|
+
|
312
|
+
4- After implementing your own log repository, you should register the class at run-time using the following syntax:
|
313
|
+
```ruby
|
314
|
+
RTALogger::LogFactory.register_log_repository :console, 'log_repository_console.rb'
|
315
|
+
```
|
316
|
+
Another example: LogRepositoryMyCustomizedUdp
|
317
|
+
|
318
|
+
```ruby
|
319
|
+
RTALogger::LogFactory.register_log_repository :my_customized_udp, 'log_repository_my_customized_udp.rb'
|
320
|
+
```
|
225
321
|
Here is 'LogRepositoryConsole' implementation:
|
226
322
|
```ruby
|
227
323
|
require_relative 'log_repository'
|
data/lib/RTALogger/version.rb
CHANGED
@@ -1,20 +1,36 @@
|
|
1
|
-
require_relative '
|
2
|
-
require_relative 'log_formatter_json'
|
1
|
+
require_relative 'log_formatter_base'
|
3
2
|
|
4
3
|
module RTALogger
|
5
4
|
# Log factory to get new instance of log formatter
|
6
5
|
module LogFactory
|
7
6
|
def self.log_formatter_default
|
8
|
-
|
9
|
-
# RTALogger::LogFormatterText.new
|
7
|
+
create_formatter(:json)
|
10
8
|
end
|
11
9
|
|
12
|
-
def self.
|
13
|
-
|
10
|
+
def self.create_formatter(type, config_json = '')
|
11
|
+
lib_file = @log_formatters[type.to_sym]
|
12
|
+
raise "unregistered formatter class: #{type.to_s}" if lib_file.nil? || lib_file.empty?
|
13
|
+
begin
|
14
|
+
load lib_file
|
15
|
+
rescue
|
16
|
+
raise "unable to load formatter class file: #{lib_file}"
|
17
|
+
end
|
18
|
+
|
19
|
+
formatter_class_name = 'RTALogger::' + ('log_formatter_' + type.to_s).split('_').map(&:capitalize).join
|
20
|
+
formatter_class = Object.const_get(formatter_class_name)
|
21
|
+
return nil unless formatter_class
|
22
|
+
result = formatter_class.new
|
23
|
+
|
24
|
+
return result if config_json.empty?
|
25
|
+
result.load_config(config_json) if result.present?
|
26
|
+
return result
|
14
27
|
end
|
15
28
|
|
16
|
-
def self.
|
17
|
-
|
29
|
+
def self.register_log_formatter(type, class_file_name)
|
30
|
+
@log_formatters[type.to_sym] = class_file_name
|
18
31
|
end
|
32
|
+
|
33
|
+
@log_formatters = {:text => 'log_formatter_text.rb',
|
34
|
+
:json => 'log_formatter_json.rb'}
|
19
35
|
end
|
20
36
|
end
|
@@ -1,56 +1,37 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'log_repository_console'
|
4
|
-
require_relative 'log_repository_file'
|
5
|
-
require_relative 'log_repository_udp'
|
6
|
-
require_relative 'log_repository_fluent'
|
7
|
-
|
8
3
|
module RTALogger
|
9
4
|
# this module generates object instance
|
10
5
|
module LogFactory
|
11
|
-
def self.
|
12
|
-
|
13
|
-
|
6
|
+
def self.create_repository(type, config_json = '')
|
7
|
+
lib_file = @log_repositories[type.to_sym]
|
8
|
+
raise "unregistered repository class: #{type.to_s}" if lib_file.nil? || lib_file.empty?
|
14
9
|
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
begin
|
11
|
+
load lib_file
|
12
|
+
rescue
|
13
|
+
raise "unable to load repository class file: #{lib_file}"
|
14
|
+
end
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
16
|
+
# repo_class_name = 'RTALogger::' + type.split('_').map(&:capitalize).join
|
17
|
+
repo_class_name = 'RTALogger::' + ('log_repository_' + type.to_s).split('_').map(&:capitalize).join
|
18
|
+
repo_class = Object.const_get(repo_class_name)
|
19
|
+
return nil unless repo_class
|
20
|
+
result = repo_class.new
|
25
21
|
|
26
|
-
|
27
|
-
|
22
|
+
# result = LogRepository.create type.to_sym
|
23
|
+
return result if config_json.empty?
|
24
|
+
result.load_config(config_json) if result.present?
|
25
|
+
return result
|
28
26
|
end
|
29
27
|
|
30
|
-
def self.
|
31
|
-
|
32
|
-
port = config_json['Port'].nil? ? 4913 : config_json['Port'].to_i
|
33
|
-
::RTALogger::LogFactory.new_log_repository_udp(host, port)
|
28
|
+
def self.register_log_repository(type, class_file_name)
|
29
|
+
@log_repositories[type.to_sym] = class_file_name
|
34
30
|
end
|
35
31
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
def self.load_log_repository_fluent(config_json)
|
41
|
-
host = config_json['Host'].to_s
|
42
|
-
port = config_json['Port'].to_s
|
43
|
-
tls_options = config_json['TLS_Options']
|
44
|
-
::RTALogger::LogFactory.new_log_repository_fluent(host, port, tls_options)
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.create_repository(type, config_json)
|
48
|
-
result = nil
|
49
|
-
result = new_log_repository_console if type.to_s.casecmp('Console').zero?
|
50
|
-
result = load_log_repository_file(config_json) if type.to_s.casecmp('File').zero?
|
51
|
-
result = load_log_repository_udp(config_json) if type.to_s.casecmp('UDP').zero?
|
52
|
-
result = load_log_repository_fluent(config_json) if type.to_s.casecmp('Fluentd').zero?
|
53
|
-
result
|
54
|
-
end
|
32
|
+
@log_repositories = {:console => 'log_repository_console.rb',
|
33
|
+
:file => 'log_repository_file.rb',
|
34
|
+
:udp => 'log_repository_upd.rb',
|
35
|
+
:fluentd => 'log_repository_fluentd.rb'}
|
55
36
|
end
|
56
37
|
end
|