Sha256: 735ed0e8589a164179fecead606de6b5a4a5ffff901f935890036ade0e27fc4c

Contents?: true

Size: 705 Bytes

Versions: 14

Compression:

Stored size: 705 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 defined?(super)
          super
        elsif respond_to?(:session)
          session.logger
        elsif instance_variable_defined?(:@session)
          @session.logger
        else
          @logger ||= Eco::Language::BasicLogger.new
        end
      end

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
eco-helpers-2.7.0 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.6.4 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.6.3 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.6.2 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.6.1 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.6.0 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.5.10 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.5.9 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.5.8 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.5.7 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.5.6 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.5.5 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.5.4 lib/eco/language/auxiliar_logger.rb
eco-helpers-2.5.3 lib/eco/language/auxiliar_logger.rb