Class: Cequel::Metal::Logger Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The Logger class encapsulates logging functionality for Keyspace.

Since:

  • 1.0.0

Direct Known Subclasses

ExceptionLogger

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out, severity, threshold = 0) ⇒ Logger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Logger.

Parameters:

  • out (::Logger)

    An instance of Logger from the standard library

  • severity (Integer)

    The severity level for this logger

  • threshold (Integer) (defaults to: 0)

    Only log queries that take longer than ‘threshold` ms

Since:

  • 1.0.0



23
24
25
# File 'lib/cequel/metal/logger.rb', line 23

def initialize(out, severity, threshold = 0)
  @out, @severity, @threshold = out, severity, threshold
end

Instance Attribute Details

#out::Logger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns An instance of Logger from the standard library.

Returns:

  • (::Logger)

    An instance of Logger from the standard library

Since:

  • 1.0.0



11
12
13
# File 'lib/cequel/metal/logger.rb', line 11

def out
  @out
end

#severityInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The severity level for this logger.

Returns:

  • (Integer)

    The severity level for this logger

Since:

  • 1.0.0



13
14
15
# File 'lib/cequel/metal/logger.rb', line 13

def severity
  @severity
end

#thresholdInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Only log queries that take longer than threshold ms.

Returns:

  • (Integer)

    Only log queries that take longer than threshold ms

Since:

  • 1.0.0



15
16
17
# File 'lib/cequel/metal/logger.rb', line 15

def threshold
  @threshold
end

Instance Method Details

#log(label, timing, statement, bind_vars) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Log a CQL statement

Parameters:

  • label (String)

    a logical label for this statement

  • timing (Integer)

    how long this statement took in ms

  • statement (String)

    the CQL statement to log

  • bind_vars (Array)

    bind variables for the CQL statement

Since:

  • 1.0.0



36
37
38
39
40
41
42
43
44
45
# File 'lib/cequel/metal/logger.rb', line 36

def log(label, timing, statement, bind_vars)
  if timing >= threshold
    out.add(severity) do
      sprintf(
        '%s (%dms) %s',
        label, timing, sanitize(statement, bind_vars)
      )
    end
  end
end