Class: Sq::Dbsync::Loggers::NullWithCallbacks

Inherits:
Abstract
  • Object
show all
Defined in:
lib/sq/dbsync/loggers.rb

Overview

Logging is one of the few outputs of the system, this class is provided as a cheap way to allow tests to hook into events. It should not be used in production.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract

#log

Constructor Details

#initialize(callbacks = nil) ⇒ NullWithCallbacks

Returns a new instance of NullWithCallbacks.



126
127
128
# File 'lib/sq/dbsync/loggers.rb', line 126

def initialize(callbacks = nil)
  @callbacks = callbacks
end

Instance Attribute Details

#callbacksObject

Returns the value of attribute callbacks.



124
125
126
# File 'lib/sq/dbsync/loggers.rb', line 124

def callbacks
  @callbacks
end

Instance Method Details

#measure(label, &block) ⇒ Object



130
131
132
133
# File 'lib/sq/dbsync/loggers.rb', line 130

def measure(label, &block)
  (callbacks || {}).fetch(label, ->{}).call
  block.call
end