Class: Ably::Logger

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/submodules/ably-ruby/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:

  • client (Ably::Rest::Client, Ably::Realtime::Client)

    Rest or Realtime Ably client

  • log_level (Integer)

    Ruby Logger log level

  • custom_logger (nil, Object) (defaults to: nil)

    A custom logger can optionally be used instead of the, however it must provide a Ruby Logger compatible interface.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/submodules/ably-ruby/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/submodules/ably-ruby/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-1.9.3/libdoc/logger/rdoc/Logger.html

Returns:

  • (Integer)


37
38
39
# File 'lib/submodules/ably-ruby/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/submodules/ably-ruby/lib/ably/logger.rb', line 29

def logger
  @logger
end