Records which queries of a database executed, were served from the memo table, or came back unchanged (early cutoff): what an edit made a graph recompute, for tests that assert the exact recompute set and for harnesses that report it.
log = Roux.QueryLog.start(db)
Roux.Input.set(db, :source, "a.ex", "changed")
MyQueries.compile(db, "a.ex")
assert Roux.QueryLog.executions(log, :parse) == ["a.ex"]
assert Roux.QueryLog.cutoffs(log, :parse) == ["a.ex"]
Roux.QueryLog.stop(log)One database
A log started for a database records only that database's events
(the database: metadata every event carries, Roux.Database.id/1),
so tests running side by side in one VM each see their own queries.
start(:all) records every database's: for a harness that drives
code which opens its database itself, such as a Mix compiler.
Lifetime
The events land in a public ETS table owned by a process of the
log's own, not linked to the caller: a test can stop/1 it from an
on_exit callback, after the test process has exited. The handler
the log attaches is VM-global until stop/1 detaches it.
Summary
Types
What happened to a query key: it executed, was served, or cut off.
Functions
Every query that kind happened to, as %{query_name => keys}, each
key list sorted: the whole window, for a harness that reports it.
The keys of query_name that executed and came back unchanged, sorted.
The keys of query_name that executed, sorted.
The keys of query_name served from the memo table without executing, sorted.
Forgets everything recorded so far: the start of a new window.
Starts a log of db's queries, or of every database's with :all.
Detaches the log's handler and deletes its table. Safe to call from any process, and more than once.
Types
Functions
Every query that kind happened to, as %{query_name => keys}, each
key list sorted: the whole window, for a harness that reports it.
The keys of query_name that executed and came back unchanged, sorted.
The keys of query_name that executed, sorted.
The keys of query_name served from the memo table without executing, sorted.
@spec reset(t()) :: :ok
Forgets everything recorded so far: the start of a new window.
@spec start(Roux.Database.t() | :all) :: t()
Starts a log of db's queries, or of every database's with :all.
@spec stop(t()) :: :ok
Detaches the log's handler and deletes its table. Safe to call from any process, and more than once.