RTALogger 1.1.1 → 2.0.0

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: b037c1dbb6f51228afd43cfc7e576e86a7e46e711b96cedaaeb9a5b3e5f3f1ec
4
- data.tar.gz: d1e2fb9ee4cddf0b221b0ec9c471117953387c502337e3d438b82348ce4111ae
3
+ metadata.gz: '09e2fc76df63cc28bd810dd7632c40e1fb7401a98ac21f3f9b837139a9a0c7a5'
4
+ data.tar.gz: 267c71efd35367fa4e70cdff396d7f9d0e9443c78963368db19b06da1cd61f07
5
5
  SHA512:
6
- metadata.gz: 1fe26e02fcdb17eb44f56644469f7061a925f5dfdc25afcde968b1d910eb5f25a13a49e25afeec8898e78eb7398bbcabe53fca3b7ca98dc85afdeae304ba12a0
7
- data.tar.gz: 11fdcff4f789f1eb739cd307c9f60c52b7f6a2816caa60699b0d1f607fba0a3cf7619e58dd17d6817b4711ba35f4998585e64a8d0f099142f8c3009210220759
6
+ metadata.gz: 9dfec223a98f1ccdaaf7c569179630698cb94d67d1554a403d5e06833dcbf90677fd1dee37aeec0c732afa9c23e931abee54cf2335f1f78b910b35593b42e1d3
7
+ data.tar.gz: 602f91b5eb2ef9b764a963727c9177e6e5ff62d8ff21d52745816b00bdd13173bdbfe40f33e3eca7374f50ca3b7e6f84809a4efbc4af70ec0247de6b2cf78b1d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- RTALogger (1.1.1)
4
+ RTALogger (2.0.0)
5
5
  fluent-logger (~> 0.9)
6
6
  jbuilder (~> 2.10)
7
7
 
data/README.md CHANGED
@@ -58,12 +58,13 @@ To use log manager APIs, first step is to have a quick review on Log Data Struct
58
58
  - At last the final element is log message, which contains log message data.
59
59
 
60
60
  ### Which Log Severity Levels to use
61
- - DEBUG = 0 : Low-level information, mostly for developers.
62
- - INFO = 1 : Generic (useful) information about system operation.
63
- - WARN = 2 : A warning, which it does NOT cause crashing the process.
64
- - ERROR = 3 : A handleable error condition.
65
- - FATAL = 4 : An un-handleable error that results in a program crash.
66
- - UNKNOWN = 5 : An unknown message that should always be logged.
61
+ - TRACE = 0 : all information that helps us to trace the processing of an incoming request through our application.
62
+ - DEBUG = 1 : Low-level information, mostly for developers.
63
+ - INFO = 2 : Generic (useful) information about system operation.
64
+ - WARN = 3 : A warning, which it does NOT cause crashing the process.
65
+ - ERROR = 4 : A handleable error condition.
66
+ - FATAL = 5 : An un-handleable error that results in a program crash.
67
+ - UNKNOWN = 6 : An unknown message that should always be logged.
67
68
 
68
69
  ### Time for coding
69
70
  - create log manager instance:
@@ -86,41 +87,61 @@ To use log manager APIs, first step is to have a quick review on Log Data Struct
86
87
  {
87
88
  "default_manager": "develop",
88
89
  "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
- ]
90
+ [
91
+ {
92
+ "title": "develop",
93
+ "enable": true,
94
+ "app_name": "TestApp",
95
+ "severity_level": "trace",
96
+ "buffer_size": 100,
97
+ "flush_wait_seconds": 10,
98
+ "repositories":
99
+ [
100
+ {
101
+ "type": "console",
102
+ "title": "console_repo_1",
103
+ "enable": true,
104
+ "formatter":
105
+ {
106
+ "type": "text",
107
+ "delimiter": "|"
108
+ }
109
+ },
110
+ {
111
+ "type": "file",
112
+ "title": "file_repo_1",
113
+ "enable": true,
114
+ "file_path": "log.txt",
115
+ "roll_period": "daily",
116
+ "roll_size": "1048576",
117
+ "formatter":
118
+ {
119
+ "type": "json",
120
+ "delimiter": "|"
121
+ }
122
+ },
123
+ {
124
+ "enable": true,
125
+ "title": "console_repo_1",
126
+ "type": "fluentd",
127
+ "host": "localhost",
128
+ "port": "8888",
129
+ "formatter":
130
+ {
131
+ "type": "json"
132
+ }
133
+ }
134
+ ],
135
+ "topics":
136
+ [
137
+ {
138
+ "title": "test",
139
+ "enable": true,
140
+ "severity_level": "WARN"
141
+ }
142
+ ]
143
+ }
144
+ ]
124
145
  }
125
146
  }
126
147
  ```
@@ -136,21 +157,25 @@ To use log manager APIs, first step is to have a quick review on Log Data Struct
136
157
  # Assume user 'Tom' is trying to authenticate we will use user_name as log Context_id
137
158
  user_name = 'Tom'
138
159
  topic = log_manager.add_topic('Authentication')
160
+ topic.trace(user_name, 'Authentication process began for:', user_name)
139
161
  topic.debug(user_name, 'use_id is nil for user:', user_name)
140
162
  topic.info(user_name, 'User ', user_name , ' is trying to login.')
141
163
  topic.warning(user_name, 'Authentication failed for user ', user_name)
142
164
  topic.error(user_name, 'Error connecting to data base for user ', user_name)
143
165
  topic.fatal(user_name, 'Authentication service has been stopped working')
144
166
  topic.unknown(user_name, 'An unknown error occured during authentication. user name:', user_name)
167
+ topic.trace(user_name, 'Authentication process end for:', user_name)
145
168
  ```
146
169
  the result will be:
147
170
  ```
171
+ {"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":"TRACE","message"Authentication process began for: Tom"}
148
172
  {"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
173
  {"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
174
  {"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
175
  {"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
176
  {"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
177
  {"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"}
178
+ {"occurred_at":"2020-11-04 15:56:58:785","app_name":"TestApp","topic_title":"Authentication","context_id":"Tom","severity":"TRACE","message"Authentication process end for: Tom"}
154
179
  ```
155
180
  - json config file sample
156
181
  ```json
@@ -161,17 +186,18 @@ the result will be:
161
186
  "log_managers":
162
187
  [
163
188
  {
164
- "manager_name": "develop",
189
+ "title": "develop",
165
190
  "enable": true,
166
191
  "app_name": "TestApp",
167
- "severity_level": "debug",
192
+ "severity_level": "trace",
168
193
  "buffer_size": 100,
169
- "flush_wait_seconds": 15,
194
+ "flush_wait_seconds": 10,
170
195
  "repositories":
171
196
  [
172
197
  {
173
- "enable": true,
174
198
  "type": "console",
199
+ "title": "console_repo_1",
200
+ "enable": true,
175
201
  "formatter":
176
202
  {
177
203
  "type": "text",
@@ -179,19 +205,21 @@ the result will be:
179
205
  }
180
206
  },
181
207
  {
182
- "enable": false,
183
208
  "type": "file",
209
+ "title": "file_repo_1",
210
+ "enable": true,
184
211
  "file_path": "log.txt",
185
212
  "roll_period": "daily",
186
213
  "roll_size": "1048576",
187
214
  "formatter":
188
215
  {
189
- "type": "text",
216
+ "type": "json",
190
217
  "delimiter": "|"
191
218
  }
192
219
  },
193
220
  {
194
- "enable": false,
221
+ "enable": true,
222
+ "title": "console_repo_1",
195
223
  "type": "fluentd",
196
224
  "host": "localhost",
197
225
  "port": "8888",
@@ -206,7 +234,7 @@ the result will be:
206
234
  {
207
235
  "title": "test",
208
236
  "enable": true,
209
- "severity_level": "info"
237
+ "severity_level": "WARN"
210
238
  }
211
239
  ]
212
240
  }
@@ -214,7 +242,7 @@ the result will be:
214
242
  }
215
243
  }
216
244
  ```
217
- - json config file structure
245
+ ### json config file structure
218
246
  ```comment
219
247
  As we described you cap apply RTA log manager using a json config file.
220
248
 
@@ -226,7 +254,7 @@ the result will be:
226
254
  multiple log manager configuration in Log_Managers array.
227
255
  - log_managers : the array of LogManagers with different configuration.
228
256
  It is possible to define multiple log manager configurations for differen usages.
229
- - manager_name: the name of log manager. It will be used to define the default log manager.
257
+ - title: the name of log manager. It will be used to define the default log manager.
230
258
  - enable: (true/false) The value of this property activate or deactivate entire log manager.
231
259
  - app_name: Application name as the owner of log data.
232
260
  - severity_level: Defines which level of log data will be stored in log repositories.
@@ -280,7 +308,7 @@ the result will be:
280
308
  - severity_level: Defines which level of log data will be stored in log repositories.
281
309
  - enable: [true/false] to enable or disable logging process of the topic.
282
310
  ```
283
- - Some useful features
311
+ ###Some useful features
284
312
  ```ruby
285
313
  # change log manager app name at run time
286
314
  log_manager.app_name = 'myTestApp'
@@ -296,8 +324,32 @@ the result will be:
296
324
 
297
325
  # enable or disable all topic if necessary
298
326
  log_manager.update_all_topics_enable([true/false])
327
+
328
+ # to get log manager configuration as json object use to_builder method
329
+ log_manager.to_builder
330
+
331
+ # to get log manager configuration as json string use reveal_config method
332
+ log_manager.reveal_config
333
+
334
+ # to apply some limited changes on log manager functionality at run time
335
+ # config_json parameter should carry a json object which contains the configuration
336
+ # structure described before in 'json configuration file structure' section.
337
+ # Attention: these changes will apply to manager but will not save.
338
+ # So during next load these changes will be lost. Save changes will be available in
339
+ # next version.
340
+ # Attention: only following attributes could be change at run time:
341
+ # log_manager.enable
342
+ # log_manager.default_severity_level
343
+ # log_manager.buffer_size (minimum is 100)
344
+ # log_manager.flush_wait_time (minimum 15 second)
345
+ # repository.enable
346
+ # topic.enable
347
+ # topic.severity_level
348
+ # Other attributes could only change via config file via manager config_use_json_file
349
+ log_manager.apply_run_time_config(config_json)
299
350
  ```
300
- - Implement and Expand
351
+ ### Implement and Expand
352
+ #### Implement new log repository
301
353
  It is possible to implement new log repositories. There will be fue rules to implement and
302
354
  integrate new customized log repository with RTALogger LogManager.
303
355
 
@@ -307,7 +359,7 @@ the result will be:
307
359
 
308
360
  3- Also appropriate naming convention is necessary.
309
361
  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
362
+ your source code should be placed in a ruby file and name it log_repository_console.rb
311
363
 
312
364
  4- After implementing your own log repository, you should register the class at run-time using the following syntax:
313
365
  ```ruby
@@ -344,17 +396,10 @@ module RTALogger
344
396
  end
345
397
  ```
346
398
 
347
- ## Development
348
-
349
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
350
-
351
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
352
-
353
399
  ## Contributing
354
400
 
355
401
  Bug reports and pull requests are welcome on GitHub at https://github.com/BBahrainy/RTALogger.
356
402
 
357
-
358
403
  ## License
359
404
 
360
405
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,3 +1,3 @@
1
1
  module RTALogger
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
@@ -20,14 +20,13 @@ module RTALogger
20
20
 
21
21
  def initialize
22
22
  @enable = true
23
- @name = 'default_log_manager'
23
+ @title = 'default_log_manager'
24
24
  @app_name = ENV.fetch('RTA_LOGGER_APP_NAME', 'unknown_app')
25
- @severity_level = ENV.fetch('RTA_LOGGER_SEVERITY_LEVEL', WARN)
25
+ @severity_level = ENV.fetch('RTA_LOGGER_SEVERITY_LEVEL', INFO)
26
26
  @config_file_name = ''
27
27
  @topic_semaphore = Mutex.new
28
28
  @log_semaphore = Mutex.new
29
29
  self.buffer_size = ENV.fetch('RTA_LOGGER_BUFFER_SIZE', 100)
30
- @flush_size = @buffer_size * 20 / 100
31
30
  self.flush_wait_time = ENV.fetch('RTA_LOGGER_FLUSH_WAIT_SECONDS', 15)
32
31
  @topics = {}
33
32
  @log_records = []
@@ -42,7 +41,7 @@ module RTALogger
42
41
  @flush_scheduler.run
43
42
  end
44
43
 
45
- attr_reader :name
44
+ attr_reader :title
46
45
  attr_accessor :enable
47
46
  attr_accessor :app_name
48
47
  attr_reader :propagator
@@ -57,6 +56,7 @@ module RTALogger
57
56
 
58
57
  def buffer_size=(size)
59
58
  @buffer_size = size < 100 ? 100 : size
59
+ @flush_size = @buffer_size * 20 / 100
60
60
  end
61
61
 
62
62
  def flush_wait_time
@@ -67,8 +67,8 @@ module RTALogger
67
67
  @flush_wait_time = time_in_seconds < 10 ? 10 : time_in_seconds
68
68
  end
69
69
 
70
- def config_use_json_file(file_name, manager_name = '')
71
- config_json = load_config_from_json_file(file_name, manager_name)
70
+ def config_use_json_file(file_name, title = '')
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
74
  rescue StandardError => e
@@ -76,8 +76,8 @@ module RTALogger
76
76
  @propagator.add_log_repository(LogFactory.create_repository(:console))
77
77
  end
78
78
 
79
- def config_use_json_string(config_string, manager_name = '')
80
- config_json = load_config_from_json_string(config_string, manager_name)
79
+ def config_use_json_string(config_string, title = '')
80
+ config_json = load_config_from_json_string(config_string, title)
81
81
  apply_config(config_json)
82
82
  rescue StandardError => e
83
83
  @propagator.drop_all_repositories
@@ -114,10 +114,22 @@ module RTALogger
114
114
  @topic_semaphore.synchronize { @topics.keys.each { |topic| @topics[topic].severity_level = severity_level } }
115
115
  end
116
116
 
117
+ def topic_by_title(title)
118
+ result = nil
119
+ @topic_semaphore.synchronize do
120
+ @topics.each do |topic|
121
+ result = topic if topic.title.casecmp(title).zero?
122
+ break if result
123
+ end
124
+ end
125
+
126
+ return result
127
+ end
128
+
117
129
  def to_builder
118
130
  @topic_semaphore.synchronize do
119
131
  jb = Jbuilder.new do |json|
120
- json.name name
132
+ json.title title
121
133
  json.enable enable
122
134
  json.app_name app_name
123
135
  json.config_file_name config_file_name
@@ -141,33 +153,50 @@ module RTALogger
141
153
  to_builder.target!
142
154
  end
143
155
 
156
+ def apply_run_time_config(config_json)
157
+ return unless config_json
158
+ @enable = config_json['enable'] unless config_json['enable'].nil?
159
+ @default_severity_level = parse_severity_level_to_i(config_json['severity_level']) unless config_json['severity_level'].nil?
160
+ self.buffer_size = config_json['buffer_size'] unless config_json['buffer_size'].nil?
161
+ self.flush_wait_time = config_json['flush_wait_time'] unless config_json['flush_wait_time'].nil?
162
+ @propagator.apply_run_time_config(config_json)
163
+
164
+ if config_json['topics']
165
+ config_json['topics'].each do |topic_config|
166
+ next if topic_config['title'].nil?
167
+ topic = topic_by_title(topic_config['title'])
168
+ topic.apply_run_time_config(topic_config) if topic
169
+ end
170
+ end
171
+ end
172
+
144
173
  private
145
174
 
146
- def load_config_from_json_file(config_file_name, manager_name = '')
175
+ def load_config_from_json_file(config_file_name, title = '')
147
176
  config_file = File.open config_file_name
148
177
  config_json = ::JSON.load(config_file)
149
- config_json = extract_config(config_json, manager_name)
178
+ config_json = extract_config(config_json, title)
150
179
  config_json
151
180
  end
152
181
 
153
- def load_config_from_json_string(config_string, manager_name = '')
182
+ def load_config_from_json_string(config_string, title = '')
154
183
  config_json = ::JSON.parse(config_string)
155
- config_json = extract_config(config_json, manager_name)
184
+ config_json = extract_config(config_json, title)
156
185
  config_json
157
186
  end
158
187
 
159
- def extract_config(json_data, manager_name = '')
188
+ def extract_config(json_data, title = '')
160
189
  config_json = json_data['rta_logger']
161
190
  raise 'RTALogger configuration not found!' unless config_json
162
191
  raise 'Log_Managers section does not exists json configuration' unless config_json['log_managers']
163
192
  raise 'No config manager defined in json configuration' unless config_json['log_managers'].count.positive?
164
- manager_name = config_json['default_manager'] if manager_name.empty?
165
- unless manager_name.to_s.strip.empty?
166
- config_json = config_json['log_managers'].find { |item| item['manager_name'] == manager_name }
193
+ title = config_json['default_manager'] if title.empty?
194
+ unless title.to_s.strip.empty?
195
+ config_json = config_json['log_managers'].find { |item| item['title'] == title }
167
196
  end
168
197
  config_json ||= config_json['log_managers'][0]
169
198
  raise 'Unable to extract RTA Log Manager configuration!' unless config_json
170
- @name = manager_name if config_json
199
+ @title = title if config_json
171
200
  config_json
172
201
  end
173
202
 
@@ -34,6 +34,30 @@ module RTALogger
34
34
  @semaphore.synchronize { @repositories.clear }
35
35
  end
36
36
 
37
+ def repository_by_title(title)
38
+ result = nil
39
+ @semaphore.synchronize do
40
+ @repositories.each do |repository|
41
+ result = repository if repository.title.casecmp(title).zero?
42
+ break if result
43
+ end
44
+ end
45
+
46
+ return result
47
+ end
48
+
49
+ def apply_run_time_config(config_json)
50
+ return unless config_json
51
+
52
+ if config_json['repositories']
53
+ config_json['repositories'].each do |repository_config|
54
+ next if repository_config['title'].nil?
55
+ repository = repository_by_title(repository_config['title'])
56
+ repository.apply_run_time_config(repository_config) if repository
57
+ end
58
+ end
59
+ end
60
+
37
61
  def propagate
38
62
  @semaphore.synchronize do
39
63
  @repositories.each do |repository|
@@ -6,6 +6,7 @@ module RTALogger
6
6
  def initialize
7
7
  @semaphore = Mutex.new
8
8
  @log_records = []
9
+ @title = self.class.to_s.split('::').last.underscore
9
10
  @enable = true
10
11
  @formatter = RTALogger::LogFactory.log_formatter_default
11
12
  end
@@ -25,6 +26,7 @@ module RTALogger
25
26
  # @@sub_classes[repository_name] = self
26
27
  # end
27
28
 
29
+ attr_accessor :title
28
30
  attr_accessor :enable
29
31
  attr_accessor :formatter
30
32
 
@@ -38,7 +40,7 @@ module RTALogger
38
40
 
39
41
  def load_config(config_json)
40
42
  @enable = config_json['enable'].nil? ? true : config_json['enable']
41
-
43
+ @title = config_json['title'].nil? ? self.class.to_s.split('::').last.underscore : config_json['title']
42
44
  formatter_config = config_json['formatter']
43
45
  if formatter_config && formatter_config['type']
44
46
  @formatter = LogFactory.create_formatter(formatter_config['type'], formatter_config)
@@ -59,6 +61,11 @@ module RTALogger
59
61
  to_builder.target!
60
62
  end
61
63
 
64
+ def appy_run_time_config(config_json)
65
+ return unless config_json
66
+ @enable = config_json['enable'] unless config_json['enable'].nil?
67
+ end
68
+
62
69
  protected
63
70
 
64
71
  def flush_and_clear
@@ -21,6 +21,10 @@ module RTALogger
21
21
  attr_reader :title
22
22
  attr_accessor :severity_level
23
23
 
24
+ def trace(context_id, *message)
25
+ add(context_id, TRACE, message) if @severity_level.to_i <= TRACE.to_i
26
+ end
27
+
24
28
  def debug(context_id, *message)
25
29
  add(context_id, DEBUG, message) if @severity_level.to_i <= DEBUG.to_i
26
30
  end
@@ -54,6 +58,13 @@ module RTALogger
54
58
 
55
59
  jb
56
60
  end
61
+
62
+ def appy_run_time_config(config_json)
63
+ return unless config_json
64
+ @enable = config_json['enable'] unless config_json['enable'].nil?
65
+ @severity_level = parse_severity_level_to_i(config_json['severity_level']) unless config_json['severity_level'].nil?
66
+ end
67
+
57
68
  private
58
69
 
59
70
  def add(context_id, severity, *message)
@@ -5,17 +5,18 @@
5
5
  "log_managers":
6
6
  [
7
7
  {
8
- "manager_name": "develop",
8
+ "title": "develop",
9
9
  "enable": true,
10
10
  "app_name": "TestApp",
11
- "severity_level": "debug",
11
+ "severity_level": "trace",
12
12
  "buffer_size": 100,
13
13
  "flush_wait_seconds": 10,
14
14
  "repositories":
15
15
  [
16
16
  {
17
- "enable": true,
18
17
  "type": "console",
18
+ "title": "console_repo_1",
19
+ "enable": true,
19
20
  "formatter":
20
21
  {
21
22
  "type": "text",
@@ -23,8 +24,9 @@
23
24
  }
24
25
  },
25
26
  {
26
- "enable": true,
27
27
  "type": "file",
28
+ "title": "file_repo_1",
29
+ "enable": true,
28
30
  "file_path": "log.txt",
29
31
  "roll_period": "daily",
30
32
  "roll_size": "1048576",
@@ -36,6 +38,7 @@
36
38
  },
37
39
  {
38
40
  "enable": true,
41
+ "title": "console_repo_1",
39
42
  "type": "fluentd",
40
43
  "host": "localhost",
41
44
  "port": "8888",
@@ -28,6 +28,7 @@ test_topic = log_manager.add_topic('test')
28
28
  # test_topic.enable = false
29
29
 
30
30
  # add log information to log topic
31
+ topic.trace(userID, 'Controller Name=', controller_name, 'trace')
31
32
  topic.debug(userID, 'Controller Name=', controller_name, 'debug')
32
33
  topic.info(userID, 'Controller Name=', controller_name, 'information')
33
34
  topic.warning(userID, 'Controller Name=', controller_name, 'warning')
@@ -1,60 +1,68 @@
1
1
  module RTALogger
2
2
  # Logging severity.
3
3
  module SeverityLevel
4
+ # all information that helps us to trace the processing of an incoming request through our application
5
+ TRACE = 0
4
6
  # Low-level information, mostly for developers.
5
- DEBUG = 0
7
+ DEBUG = 1
6
8
  # Generic (useful) information about system operation.
7
- INFO = 1
9
+ INFO = 2
8
10
  # A warning.
9
- WARN = 2
11
+ WARN = 3
10
12
  # A handleable error condition.
11
- ERROR = 3
13
+ ERROR = 4
12
14
  # An un-handleable error that results in a program crash.
13
- FATAL = 4
15
+ FATAL = 5
14
16
  # An unknown message that should always be logged.
15
- UNKNOWN = 5
17
+ UNKNOWN = 6
16
18
 
17
19
 
18
20
  def parse_severity_level_to_i(severity_level)
19
21
  return severity_level if severity_level.is_a? ::Integer
20
22
 
21
23
  case severity_level.upcase
22
- when 'DEBUG'
24
+ when 'TRACE'
23
25
  0
24
- when 'INFO'
26
+ when 'DEBUG'
25
27
  1
28
+ when 'INFO'
29
+ 2
26
30
  when 'INFORMATIONّٔ'
27
- 1
28
- when 'WARN'
29
31
  2
32
+ when 'WARN'
33
+ 3
30
34
  when 'WARNING'
31
- 2
35
+ 5
32
36
  when 'ERROR'
33
- 3
34
- when 'FATAL'
35
37
  4
36
- when 'UNKNOWN'
38
+ when 'FATAL'
37
39
  5
40
+ when 'UNKNOWN'
41
+ 6
42
+ else
43
+ 2
38
44
  end
39
- end
45
+ end
40
46
 
41
- def parse_severity_level_to_s(severity_level)
42
- return severity_level if severity_level.is_a? ::String
47
+ def parse_severity_level_to_s(severity_level)
48
+ return severity_level if severity_level.is_a? ::String
43
49
 
44
- case severity_level.to_i
45
- when 0
46
- 'DEBUG'
47
- when 1
48
- 'INFO'
49
- when 2
50
- 'WARN'
51
- when 3
52
- 'ERROR'
53
- when 4
54
- 'FATAL'
55
- when 5
56
- 'UNKNOWN'
57
- end
50
+ case severity_level.to_i
51
+ when 0
52
+ 'TRACE'
53
+ when 1
54
+ 'DEBUG'
55
+ when 2
56
+ 'INFO'
57
+ when 3
58
+ 'WARN'
59
+ when 4
60
+ 'ERROR'
61
+ when 5
62
+ 'FATAL'
63
+ when 6
64
+ 'UNKNOWN'
58
65
  end
59
66
  end
60
67
  end
68
+ end
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: 1.1.1
4
+ version: 2.0.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-26 00:00:00.000000000 Z
11
+ date: 2020-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluent-logger