module RTALogger::LogFactory

Log factory to get new instance of log filter

Log factory to get new instance of log formatter

this module generates object instance

this module generates object instance

this module generates object instance

this module generates object instance

this module generates object instance

Public Class Methods

create_filter(type, config_json = '') click to toggle source
# File lib/log_factory_filter.rb, line 6
def self.create_filter(type, config_json = '')
  lib_file = @log_filters[type.to_sym]
  raise "unregistered filter class: #{type.to_s}" if lib_file.nil? || lib_file.empty?
  begin
    load lib_file
  rescue
    raise "unable to load filter class file: #{lib_file}"
  end

  filter_class_name = 'RTALogger::' + ('log_filter_' + type.to_s).split('_').map(&:capitalize).join
  filter_class = Object.const_get(filter_class_name)
  return nil unless filter_class
  result = filter_class.new

  return result if config_json.empty?
  result.load_config(config_json) if result.present?
  return result
end
create_formatter(type, config_json = '') click to toggle source
# File lib/log_factory_log_formatter.rb, line 10
def self.create_formatter(type, config_json = '')
  lib_file = @log_formatters[type.to_sym]
  raise "unregistered formatter class: #{type.to_s}" if lib_file.nil? || lib_file.empty?
  begin
    load lib_file
  rescue
    raise "unable to load formatter class file: #{lib_file}"
  end

  formatter_class_name = 'RTALogger::' + ('log_formatter_' + type.to_s).split('_').map(&:capitalize).join
  formatter_class = Object.const_get(formatter_class_name)
  return nil unless formatter_class
  result = formatter_class.new

  return result if config_json.nil? || config_json.empty?
  result.load_config(config_json) if result.present?
  return result
end
create_repository(type, config_json = '') click to toggle source
# File lib/log_factory_repository.rb, line 6
def self.create_repository(type, config_json = '')
  lib_file = @log_repositories[type.to_sym]
  raise "unregistered repository class: #{type.to_s}" if lib_file.nil? || lib_file.empty?

  begin
    load lib_file
  rescue
    raise "unable to load repository class file: #{lib_file}"
  end

  # repo_class_name = 'RTALogger::' + type.split('_').map(&:capitalize).join
  repo_class_name = 'RTALogger::' + ('log_repository_' + type.to_s).split('_').map(&:capitalize).join
  repo_class = Object.const_get(repo_class_name)
  return nil unless repo_class
  result = repo_class.new

  # result = LogRepository.create type.to_sym
  return result if config_json.empty?
  result.load_config(config_json) if result.present?
  return result
end
log_formatter_default() click to toggle source
# File lib/log_factory_log_formatter.rb, line 6
def self.log_formatter_default
  create_formatter(:json)
end
log_manager_instance() click to toggle source
# File lib/log_factory_manager.rb, line 8
def self.log_manager_instance
  RTALogger::LogManager.instance
end
new_log_propagator() click to toggle source
# File lib/log_factory_propagator.rb, line 8
def self.new_log_propagator
  LogPropagator.new
end
new_log_record(log_topic, context_id, severity, *message) click to toggle source
# File lib/log_factory_record.rb, line 8
def self.new_log_record(log_topic, context_id, severity, *message)
  LogRecord.new(log_topic, context_id, severity, message)
end
new_log_topic(log_manager, title, level = WARN, enable = true) click to toggle source
# File lib/log_factory_topic.rb, line 8
def self.new_log_topic(log_manager, title, level = WARN, enable = true)
  LogTopic.new(log_manager, title, level, enable)
end
register_log_filter(type, class_file_name) click to toggle source
# File lib/log_factory_filter.rb, line 25
def self.register_log_filter(type, class_file_name)
  @log_filters[type.to_sym] = class_file_name
end
register_log_formatter(type, class_file_name) click to toggle source
# File lib/log_factory_log_formatter.rb, line 29
def self.register_log_formatter(type, class_file_name)
  @log_formatters[type.to_sym] = class_file_name
end
register_log_repository(type, class_file_name) click to toggle source
# File lib/log_factory_repository.rb, line 28
def self.register_log_repository(type, class_file_name)
  @log_repositories[type.to_sym] = class_file_name
end