module LogHelper
Helper for setting up logging
Public Instance Methods
initialize_logger(plugin_file, class_name, options)
click to toggle source
# File lib/core/helpers/log_helper.rb, line 49 def initialize_logger(plugin_file, class_name, options) # rubocop:disable all return eval(plugin_file.module_class_name).new(class_name, options) # rubocop:enable all end
load_logger(class_name, options)
click to toggle source
rubocop:enable all
# File lib/core/helpers/log_helper.rb, line 41 def load_logger(class_name, options) PluginLoader.find_plugin_files("logger").each do |plugin_file| next unless plugin_file.instance_name.downcase == options[:output_format] require plugin_file.absolute_path return initialize_logger(plugin_file, class_name, options) end end
log_file_path(file_path, conf = Conf)
click to toggle source
# File lib/core/helpers/log_helper.rb, line 6 def log_file_path(file_path, conf = Conf) return false if !file_path || file_path.nil? file_path == "log_file" ? conf.log.file.path : file_path end
output_format(log_file, conf = Conf)
click to toggle source
# File lib/core/helpers/log_helper.rb, line 20 def output_format(log_file, conf = Conf) log_file ? conf.log.file.message_format : conf.log.message_format end
output_formatter(format, plugin_name)
click to toggle source
rubocop:disable all Unused variables are made available for the output formatting
# File lib/core/helpers/log_helper.rb, line 26 def output_formatter(format, plugin_name) proc do |severity, datetime, progname, msg| # Requiring time fixes a bug where not # all Time methods where available such # as iso8601 used in the default .radial.yml require 'time' pid = Process.pid severity_id = severity[0] severity_label = severity eval('"' + format.to_s + '\n"') end end
parse_log_level(level, conf = Conf)
click to toggle source
# File lib/core/helpers/log_helper.rb, line 11 def parse_log_level(level, conf = Conf) level_options = conf.log.level_options matched_level = level_options.select { |l| l.upcase.start_with? level.upcase }.first parsed_level = matched_level || level_options[1] # rubocop:disable all eval("Logger::#{parsed_level.upcase}") # rubocop:enable all end