Sha256: 71e7871222f73482a122be32854631e924cd2735d67c68218ee5658ddfdb15d0

Contents?: true

Size: 1.01 KB

Versions: 12

Compression:

Stored size: 1.01 KB

Contents

require 'logger'


module Climatic
  module Logger

    module Manager

      attr_reader :logger

      def puts_and_logs(*args)
        logger.puts_and_logs *args
      end

      def logger=(new_logger)

        new_logger ||= DEVNULL_LOGGER

        unless climatic_bootstrapped? or climatic_bootstrapping?
          @user_defined_logger = new_logger
          return
        end

        if climatic_bootstrapped?
          new_logger.level = config[:'log-level'].nil? ? Climatic::Logger::Manager::DEFAULT_LOG_LEVEL : config[:'log-level']
        end

        new_logger.extend Climatic::Logger::Wrapper

        if self.logger.respond_to? :transfer_content_to
          self.logger.transfer_content_to new_logger
        end

        UltraCommandLine.logger = new_logger
        @logger = new_logger
      end

      protected

      attr_reader :user_defined_logger

      private

      DEFAULT_LOG_LEVEL = ::Logger::Severity::WARN
      DEVNULL_LOGGER = UltraCommandLine::Utils::BasicLogger::NullLogger.new

    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
climatic-0.2.38 lib/climatic/logger/manager.rb
climatic-0.2.37 lib/climatic/logger/manager.rb
climatic-0.2.36 lib/climatic/logger/manager.rb
climatic-0.2.35 lib/climatic/logger/manager.rb
climatic-0.2.34 lib/climatic/logger/manager.rb
climatic-0.2.32 lib/climatic/logger/manager.rb
climatic-0.2.31 lib/climatic/logger/manager.rb
climatic-0.2.30 lib/climatic/logger/manager.rb
climatic-0.2.29 lib/climatic/logger/manager.rb
climatic-0.2.28 lib/climatic/logger/manager.rb
climatic-0.2.27 lib/climatic/logger/manager.rb
climatic-0.2.26 lib/climatic/logger/manager.rb