7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/cassandra-orm/logger.rb', line 7
def self.included base
base.extend self
base.singleton_class.class_exec do
def logger
@logger ||= cluster.instance_variable_get :@logger
end
private :logger
def execute identifier, statement, options = {}
debug identifier, _fetch_cql(statement).strip, options[:arguments] do
session.execute statement, options
end
end
def execute_async identifier, statement, options = {}
logger.info log_message(identifier, _fetch_cql(statement).strip, options[:arguments])
session.execute_async statement, options
end
def _fetch_cql statement
case statement
when String, Cassandra::Statements::Simple then statement
when Cassandra::Statements::Prepared, Cassandra::Statements::Bound then statement.cql
when Cassandra::Statements::Batch then "[#{statement.statements.join('; ')}]"
else statement.inspect
end
end
private :_fetch_cql
end
end
|