Class: Jfrog::Saas::Log::ConfigHandler

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/jfrog/saas/log/confighandler.rb

Constant Summary collapse

@@file_name =
''

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfigHandler

Returns a new instance of ConfigHandler.



257
258
259
260
261
262
263
264
265
266
# File 'lib/jfrog/saas/log/confighandler.rb', line 257

def initialize
  @mutex = Mutex.new
  # If not found in options, check for the environment variable
  @config_path = if !@@file_name.nil?
                   @@file_name
                 else
                   ENV['LOG_COLLECTOR_CONFIG']
                 end
  load_all_config(@config_path, 'initialize')
end

Class Attribute Details

.conn_configObject (readonly)

Returns the value of attribute conn_config.



244
245
246
# File 'lib/jfrog/saas/log/confighandler.rb', line 244

def conn_config
  @conn_config
end

.log_configObject (readonly)

Returns the value of attribute log_config.



248
249
250
# File 'lib/jfrog/saas/log/confighandler.rb', line 248

def log_config
  @log_config
end

.proc_configObject (readonly)

Returns the value of attribute proc_config.



252
253
254
# File 'lib/jfrog/saas/log/confighandler.rb', line 252

def proc_config
  @proc_config
end

Instance Attribute Details

#conn_configObject

Returns the value of attribute conn_config.



255
256
257
# File 'lib/jfrog/saas/log/confighandler.rb', line 255

def conn_config
  @conn_config
end

#file_nameObject

Returns the value of attribute file_name.



255
256
257
# File 'lib/jfrog/saas/log/confighandler.rb', line 255

def file_name
  @file_name
end

#log_configObject

Returns the value of attribute log_config.



255
256
257
# File 'lib/jfrog/saas/log/confighandler.rb', line 255

def log_config
  @log_config
end

#proc_configObject

Returns the value of attribute proc_config.



255
256
257
# File 'lib/jfrog/saas/log/confighandler.rb', line 255

def proc_config
  @proc_config
end

Class Method Details

.file_name(file_name) ⇒ Object



239
240
241
# File 'lib/jfrog/saas/log/confighandler.rb', line 239

def self.file_name(file_name)
  @@file_name = file_name
end

Instance Method Details

#load_all_config(config_file, thread_name) ⇒ Object



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/jfrog/saas/log/confighandler.rb', line 268

def load_all_config(config_file, thread_name)
  @mutex.synchronize do
    if !config_file.nil?
      @log_config = LogConfig.instance
      @log_config.configure(config_file)
      @conn_config = ConnectionConfig.instance
      @conn_config.configure(config_file)
      @proc_config = ProcessConfig.instance
      @proc_config.configure(config_file)

      MessageUtils.instance.log_message(MessageUtils::CONFIG_LOAD_BEGIN, { "param1": thread_name, "param2": config_file, "#{MessageUtils::LOG_LEVEL}": CommonUtils::LOG_INFO })
      if LogConfig.instance.debug_mode == true
        MessageUtils.instance.log_message(MessageUtils::CONFIG_LOAD_DETAIL, { "param1": thread_name, "param2": @conn_config.to_s, "#{MessageUtils::LOG_LEVEL}": CommonUtils::LOG_DEBUG })
      end
      if LogConfig.instance.debug_mode == true
        MessageUtils.instance.log_message(MessageUtils::CONFIG_LOAD_DETAIL, { "param1": thread_name, "param2": @log_config.to_s, "#{MessageUtils::LOG_LEVEL}": CommonUtils::LOG_DEBUG })
      end
      if LogConfig.instance.debug_mode == true
        MessageUtils.instance.log_message(MessageUtils::CONFIG_LOAD_DETAIL, { "param1": thread_name, "param2": @proc_config.to_s, "#{MessageUtils::LOG_LEVEL}": CommonUtils::LOG_DEBUG })
      end
      MessageUtils.instance.log_message(MessageUtils::CONFIG_LOAD_END, { "param1": thread_name, "param2": config_file, "#{MessageUtils::LOG_LEVEL}": CommonUtils::LOG_INFO })
    else
      MessageUtils.instance.log_message(MessageUtils::CONFIG_ERROR_NO_FILE, { "#{MessageUtils::LOG_LEVEL}": CommonUtils::LOG_ERROR })
    end
  end
end