Add the ability to emit logging messages from a `DbTx` transaction
Fixes #499 (closed).
The fix required passing a few constraints around unfortunately, but now we can emit logging messages directly from a DbTx block, which means we don't have to split our transactions anymore in order to log things. For example, now we can do:
runDBTx $ do
corpus_node <- getNode l -- (Proxy :: Proxy HyperdataList)
let corpus_id = fromMaybe (panicTrace "no parent_id") (_node_parent_id corpus_node)
$(txLogLocM) DEBUG "[postAsyncJSON] Executing re-indexing..."
_ <- reIndexWith env corpus_id l NgramsTerms (Set.fromList [MapTerm, CandidateTerm])
$(txLogLocM) DEBUG "[postAsyncJSON] Re-indexing done."
Previously we were forced to run the first part of the transaction, emit the logs, run the second part, meaning that if we had a problem in the second part, the first part wouldn't rollback correctly.
A txLogLocM function has been added to log inside a DbTx monad, which has the same API as logLocM.