class Testify::Tracker::LogTracer
- Testify::Tracker::LogTracer
- Reference
- Object
Overview
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
Defined in:
tracer/log_tracer.crConstructors
Instance Method Summary
-
#add(name : String | Symbol, message : String? = nil)
Creates a trace referenced to the name namespace.
-
#size(name : String | Symbol) : Int32
Returns the number of traces performed.
- #tracer : Tracer(String)
-
#traces
Returns all traces.
Constructor Detail
Instance Method Detail
def add(name : String | Symbol, message : String? = nil)
#
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
.