Class: Faye::Redis::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/faye/redis/logger.rb

Constant Summary collapse

LEVELS =
{
  silent: 0,
  error: 1,
  info: 2,
  debug: 3
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component, options = {}) ⇒ Logger

Returns a new instance of Logger.



13
14
15
16
17
# File 'lib/faye/redis/logger.rb', line 13

def initialize(component, options = {})
  @component = component
  level_name = options[:log_level] || :info
  @level = LEVELS[level_name] || LEVELS[:info]
end

Instance Attribute Details

#componentObject (readonly)

Returns the value of attribute component.



11
12
13
# File 'lib/faye/redis/logger.rb', line 11

def component
  @component
end

#levelObject (readonly)

Returns the value of attribute level.



11
12
13
# File 'lib/faye/redis/logger.rb', line 11

def level
  @level
end

Instance Method Details

#debug(message) ⇒ Object



27
28
29
# File 'lib/faye/redis/logger.rb', line 27

def debug(message)
  log(:debug, message) if @level >= LEVELS[:debug]
end

#error(message) ⇒ Object



19
20
21
# File 'lib/faye/redis/logger.rb', line 19

def error(message)
  log(:error, message) if @level >= LEVELS[:error]
end

#info(message) ⇒ Object



23
24
25
# File 'lib/faye/redis/logger.rb', line 23

def info(message)
  log(:info, message) if @level >= LEVELS[:info]
end