Module: Eco::Language::AuxiliarLogger

Overview

Some modules/classes use logger, but they may not be connected to session. This prevents errors with this.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

Provides either an available logger or a basic one



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/eco/language/auxiliar_logger.rb', line 9

def logger
  if instance_variable_defined?(:@session) && !@session.nil?
    @session.logger
  elsif respond_to?(:session)
    session.logger
  elsif Object.const_defined?(:ASSETS)
    ASSETS.session.logger
  elsif defined?(super)
    super
  else
    @logger ||= Eco::Language::BasicLogger.new
  end
end

Instance Method Details

#log(level, &block) ⇒ Object

Shortcut to logger.



24
25
26
27
28
# File 'lib/eco/language/auxiliar_logger.rb', line 24

def log(level, &block)
  return unless logger.respond_to?(:level)

  logger&.send(level, &block)
end