Sha256: 2d021d6ecff57e46fa6fc3c44bf1c32c2b77e3820a5b98f524d8d14c290b320f

Contents?: true

Size: 697 Bytes

Versions: 8

Compression:

Stored size: 697 Bytes

Contents

require "logger"
module Boty
  module Logger
    attr_writer :logger

    def self.adapter=(adapter)
      @adapter = adapter
    end

    def self.adapter
      @adapter ||= ::Logger.new(STDOUT).tap { |logger|
        logger.level = ::Logger::DEBUG
      }
    end

    def logger
      Logger.adapter
    end

    def log_level(level)
      logger.level = level
    end

    class Memory < ::Logger
      attr_reader :logs

      def initialize(*args)
        @logs = []
      end

      def add(*args, &block)
        _, _, message = args
        @logs << message
      end
    end

    class Null < ::Logger
      def initialize(*args); end
      def add(*args, &block); end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
boty-0.0.17.1 lib/boty/logger.rb
boty-0.0.17 lib/boty/logger.rb
boty-0.0.16 lib/boty/logger.rb
boty-0.0.15 lib/boty/logger.rb
boty-0.0.14 lib/boty/logger.rb
boty-0.0.13 lib/boty/logger.rb
boty-0.0.12 lib/boty/logger.rb
boty-0.0.11 lib/boty/logger.rb