Module: Kanina::Logger

Included in:
Server, Subscription
Defined in:
lib/kanina/logger.rb

Overview

Kanina::Logger simplifies sending messages to standard output and/or the Rails log files.

Constant Summary collapse

DEFAULT_LOG_LEVEL =
::Logger::INFO

Instance Method Summary collapse

Instance Method Details

#loggerRails::Logger

Sets up the Rails logger

Returns:

  • (Rails::Logger)

    the logger being used



11
12
13
14
# File 'lib/kanina/logger.rb', line 11

def logger
  Rails.logger ||= ::Logger.new(STDOUT)
  @logger ||= Rails.logger
end

#say(text, level = DEFAULT_LOG_LEVEL) ⇒ Object

Sends a message to the log

Parameters:

  • text (String)

    the message to log

  • level (defaults to: DEFAULT_LOG_LEVEL)

    the importance of the logged message. Default is Logger::INFO



19
20
21
22
# File 'lib/kanina/logger.rb', line 19

def say(text, level = DEFAULT_LOG_LEVEL)
  puts text if @loud
  logger.add level, "HARE: #{text}"
end