lib/factbase/looged.rb in factbase-0.0.48 vs lib/factbase/looged.rb in factbase-0.0.49

- old
+ new

@@ -20,10 +20,11 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. require 'time' require 'loog' +require 'tago' require_relative 'syntax' # A decorator of a Factbase, that logs all operations. # Author:: Yegor Bugayenko (yegor256@gmail.com) # Copyright:: Copyright (c) 2024 Yegor Bugayenko @@ -57,10 +58,13 @@ tail = nil r = @fb.txn(this) do |fbt| tail = Factbase::Looged.elapsed do yield fbt end + rescue Factbase::Rollback => e + @loog.debug('Txn rolled back') + raise e end @loog.debug("Txn #{r ? 'modified' : 'didn\'t touch'} #{before} facts #{tail}") r end @@ -170,8 +174,8 @@ end def self.elapsed start = Time.now yield - "in #{format('%.2f', (Time.now - start) * 1000)}ms" + "in #{start.ago}" end end