Testify::Tracker::LogTracer
A simple Tracer implementation that logs calls.
By default it logs the number of calls of the add method
but it is possible to specify a different message to the add method.
class ExampleTest < Testify::Test
include Testify::Tracker
def initialize
@tracer = LogTracer.new
log_trace(:initialize)
log_trace(:key_is_a_symbol_or_string)
log_trace("foo", "bar")
log_trace("foo", "another trace for foo")
end
def log_trace(name : String | Symbol, message : String? = nil) : Nil
@tracer.add(name, message)
end
def tracer_size(name : String | Symbol) : Int32
@tracer.size(name)
end
def tracer : LogTracer
@tracer
end
def test_example_tracer
tracer_size("foo").should eq 2
# debug
pp tracer.get("foo")
end
end
Constructors
new
SourceInstance methods
Creates a trace referenced to the name namespace.
The default message is the increment number of the current call (#1, #2, #3, ...).
See Tracer#add.