Class: Cassandra::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/cassandra/cassandra_logger.rb

Overview

This class is a logger that may be used by the client to log the driver's actions. It is a subclass of the standard Ruby Logger class, so it is instantiated the same way.

The format of log output is set to include the timestamp, thread-id, log severity, and message. This format may change in newer versions of the driver to account for new/deprecated metadata.

Examples:

Configuring Cluster to use a logger.

cluster = Cassandra.cluster(logger: Cassandra::Logger.new($stderr))

The log format may be changed the same way as in the standard Ruby Logger class

logger = Cassandra::Logger.new($stderr)
logger.formatter = proc { |severity, time, program_name, message|
  "[%s]: %s\n" % [severity, message]
}

Create a logger and use it in your own business logic

logger = Cassandra::Logger.new($stderr)
cluster = Cassandra.cluster(logger: logger)
<various logic>
logger.debug("something interesting happened.")

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Logger

Returns a new instance of Logger.



75
76
77
78
# File 'lib/cassandra/cassandra_logger.rb', line 75

def initialize(*args)
  super(*args)
  self.formatter = Formatter.new
end