Module: Faye::Logging

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

Constant Summary

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

+ (Object) log_level



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

def log_level
  @log_level || DEFAULT_LOG_LEVEL
end

Instance Attribute Details

- (Object) log_level



30
31
32
# File 'lib/faye/mixins/logging.rb', line 30

def log_level
  @log_level || Logging.log_level
end

Instance Method Details

- (Object) log(message_args, level)



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/faye/mixins/logging.rb', line 34

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 }] "
  
  puts(timestamp + banner + message)
end