Sha256: 34e46b770506f0b33f5879017cfbb35f1ea26348cb23fd9911c968caf2462c6e

Contents?: true

Size: 658 Bytes

Versions: 3

Compression:

Stored size: 658 Bytes

Contents

require 'logger'

module Kanina
  # `Kanina::Logger` simplifies sending messages to standard output and/or the
  # Rails log files.
  module Logger
    DEFAULT_LOG_LEVEL = ::Logger::INFO

    # Sets up the Rails logger
    # @return [Rails::Logger] the logger being used
    def logger
      Rails.logger ||= ::Logger.new(STDOUT)
      @logger ||= Rails.logger
    end

    # Sends a message to the log
    # @param text [String] the message to log
    # @param level the importance of the logged message. Default is Logger::INFO
    def say(text, level = DEFAULT_LOG_LEVEL)
      puts text if @loud
      logger.add level, "HARE: #{text}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kanina-0.7.0 lib/kanina/logger.rb
kanina-0.6.2 lib/kanina/logger.rb
kanina-0.6.1 lib/kanina/logger.rb