Module: Faye::Logging

Included in:
Client, Engine::Proxy, Extensible, RackAdapter, Server, Transport
Defined in:
lib/faye/mixins/logging.rb

Constant Summary collapse

DEFAULT_LOG_LEVEL =
:error
LOG_LEVELS =
{
  :error  => 3,
  :warn   => 2,
  :info   => 1,
  :debug  => 0
}

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.log_levelObject



16
17
18
# File 'lib/faye/mixins/logging.rb', line 16

def log_level
  @log_level || DEFAULT_LOG_LEVEL
end

Instance Attribute Details

#log_levelObject



23
24
25
# File 'lib/faye/mixins/logging.rb', line 23

def log_level
  @log_level || Logging.log_level
end

Instance Method Details

#log(message_args, level) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/faye/mixins/logging.rb', line 27

def log(message_args, level)
  return unless Faye.logger
  return if LOG_LEVELS[log_level] > LOG_LEVELS[level]
  
  message = message_args.shift.gsub(/\?/) do
    Faye.to_json(message_args.shift)
  end
  
  timestamp = Time.now.strftime('%Y-%m-%d %H:%M:%S')
  banner = " [#{ level.to_s.upcase }] [#{ self.class.name }] "
  
  Faye.logger.call(timestamp + banner + message)
end