lib/legion/logging/builder.rb in legion-logging-0.2.0 vs lib/legion/logging/builder.rb in legion-logging-0.3.1
- old
+ new
@@ -1,38 +1,20 @@
module Legion
module Logging
module Builder
- def log_format(options = {}, log = @log) # rubocop:disable Metrics/AbcSize
+ def log_format(_options = {}, log = @log)
log.formatter = proc do |severity, datetime, _progname, msg|
- options[:lex_name] = options.key?(:lex) ? "[lex-#{options[:lex]}]" : nil
- unless options[:lex_name].nil?
- data = caller_locations[4].to_s.split('/').last(2)
- runner_trace = {
- type: data[0],
- file: file = data[1].split('.')[0], # rubocop:disable Lint/UselessAssignment
- function: data[1].split('`')[1].delete_suffix('\''),
- line_number: line_number = data[1].split(':')[1] # rubocop:disable Lint/UselessAssignment
- }
- end
- string = "[#{datetime}][#{::Process.pid}]"
- string.concat(options[:lex_name]) unless options[:lex_name].nil?
- if runner_trace.is_a?(Hash) && options[:extended]
- string.concat("[#{runner_trace[:file]}:#{runner_trace[:line_number]}]")
- end
- string.concat(" #{severity} #{msg}\n")
- string
+ "[#{datetime}][#{::Process.pid}] #{severity} #{msg}\n"
end
end
def output(options)
@log = ::Logger.new($stdout) if options[:log_file].nil?
@log = ::Logger.new(options[:log_file]) unless options[:log_file].nil?
end
- def log_level(level = 'debug', log = @log) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
- if level == 'trace'
- log.level = ::Logger::INFO
- elsif level == 'debug'
+ def log_level(level = 'debug', log = @log)
+ if level == 'debug'
log.level = ::Logger::DEBUG
elsif level == 'info'
log.level = ::Logger::INFO
elsif level == 'warn'
log.level = ::Logger::WARN