lib/legion/extensions/helpers/logger.rb in legionio-0.2.0 vs lib/legion/extensions/helpers/logger.rb in legionio-0.3.0
- old
+ new
@@ -1,27 +1,26 @@
-# frozen_string_literal: true
-
module Legion
module Extensions
module Helpers
module Logger
- def log
+ def log # rubocop:disable Metrics/AbcSize
return @log unless @log.nil?
logger_hash = { lex: lex_filename || nil }
logger_hash[:lex] = lex_filename.first if logger_hash[:lex].is_a? Array
if respond_to?(:settings) && settings.key?(:logger)
logger_hash[:level] = settings[:logger][:level] if settings[:logger].key? :level
logger_hash[:level] = settings[:logger][:log_file] if settings[:logger].key? :log_file
+ logger_hash[:level] = 'info' unless settings[:logger].key? :log_file
logger_hash[:trace] = settings[:logger][:trace] if settings[:logger].key? :trace
logger_hash[:extended] = settings[:logger][:extended] if settings[:logger].key? :extended
elsif respond_to?(:settings)
Legion::Logging.warn Legion::Settings[:extensions][lex_filename.to_sym]
Legion::Logging.warn "#{lex_name} has settings but no :logger key"
else
Legion::Logging.warn 'no settings'
end
- @log = Legion::Logging::Logger.new(logger_hash)
+ @log = Legion::Logging::Logger.new(**logger_hash)
end
def handle_exception(exception, task_id: nil, **opts)
log.error exception.message + " for task_id: #{task_id} but was logged "
log.error exception.backtrace[0..10]