Class: Ably::Logger

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ably/logger.rb

Overview

Logger unifies logging for #debug, #info, #warn, #error, and #fatal messages. A new Ably client uses this Logger and sets the appropriate log level. A custom Logger can be configured when instantiating the client, refer to the Rest::Client and Realtime::Client documentation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, log_level, custom_logger = nil) ⇒ Logger

Returns a new instance of Logger.

Parameters:



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ably/logger.rb', line 14

def initialize(client, log_level, custom_logger = nil)
  @client        = client
  @custom_logger = custom_logger
  @logger        = custom_logger || default_logger
  @log_level     = log_level

  ensure_logger_interface_is_valid

  @logger.level = log_level

  @log_mutex = Mutex.new
end

Instance Attribute Details

#custom_loggernil, Object (readonly)

If a custom logger is being used with this Logger, this property is not nil

Returns:

  • (nil, Object)


33
34
35
# File 'lib/ably/logger.rb', line 33

def custom_logger
  @custom_logger
end

#log_levelInteger (readonly)

The log level ranging from DEBUG to FATAL, refer to www.ruby-doc.org/stdlib-3.1.1/libdoc/logger/rdoc/Logger.html

Returns:

  • (Integer)


37
38
39
# File 'lib/ably/logger.rb', line 37

def log_level
  @log_level
end

#loggerObject, Logger (readonly)

The logger used by this class, defaults to Ruby Logger

Returns:



29
30
31
# File 'lib/ably/logger.rb', line 29

def logger
  @logger
end