Sha256: e2516b80a74e4278c50c0e3bda3dfcf37e0893d68d0de7fd7ba569e0ad90bd82

Contents?: true

Size: 793 Bytes

Versions: 22

Compression:

Stored size: 793 Bytes

Contents

module Eco
  module Language
    # Some modules/classes use logger, but they may not be connected to session.
    # This prevents errors with this.
    module AuxiliarLogger
      attr_writer :logger

      # Provides either an available logger or a basic one
      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

      # Shortcut to logger.
      def log(level, &block)
        logger&.send(level, &block)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
eco-helpers-3.0.4 lib/eco/language/auxiliar_logger.rb
eco-helpers-3.0.3 lib/eco/language/auxiliar_logger.rb
eco-helpers-3.0.2 lib/eco/language/auxiliar_logger.rb
eco-helpers-3.0.1 lib/eco/language/auxiliar_logger.rb
eco-helpers-3.0.0 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.25 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.24 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.23 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.22 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.21 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.20 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.19 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.18 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.17 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.16 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.15 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.14 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.13 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.12 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.7.4 lib/eco/language/auxiliar_logger.rb