From 323e6771829df243077f3d02301a3a281e4e02da Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sun, 7 Aug 2022 03:01:39 -0400 Subject: [PATCH] enable logging of salsa events by default and add logging to tests --- components/salsa-2022/src/database.rs | 7 +++++-- salsa-2022-tests/Cargo.toml | 3 ++- salsa-2022-tests/tests/hello_world.rs | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/components/salsa-2022/src/database.rs b/components/salsa-2022/src/database.rs index fd6b1b72..c6077f45 100644 --- a/components/salsa-2022/src/database.rs +++ b/components/salsa-2022/src/database.rs @@ -1,11 +1,14 @@ -use crate::{storage::HasJarsDyn, Event, Runtime}; +use crate::{storage::HasJarsDyn, DebugWithDb, Event, Runtime}; pub trait Database: HasJarsDyn + AsSalsaDatabase { /// This function is invoked at key points in the salsa /// runtime. It permits the database to be customized and to /// inject logging or other custom behavior. + /// + /// By default, the event is logged at level debug using + /// the standard `log` facade. fn salsa_event(&self, event_fn: Event) { - #![allow(unused_variables)] + log::debug!("salsa_event: {:?}", event_fn.debug(self)); } fn salsa_runtime(&self) -> &Runtime; diff --git a/salsa-2022-tests/Cargo.toml b/salsa-2022-tests/Cargo.toml index edd31a4e..d703b211 100644 --- a/salsa-2022-tests/Cargo.toml +++ b/salsa-2022-tests/Cargo.toml @@ -9,4 +9,5 @@ edition = "2021" salsa = { path = "../components/salsa-2022", package = "salsa-2022" } expect-test = "1.4.0" parking_lot = "0.12.1" - +test-log = "0.2.11" +env_logger = "*" diff --git a/salsa-2022-tests/tests/hello_world.rs b/salsa-2022-tests/tests/hello_world.rs index 1c03a822..c12ea5de 100644 --- a/salsa-2022-tests/tests/hello_world.rs +++ b/salsa-2022-tests/tests/hello_world.rs @@ -5,6 +5,7 @@ use salsa_2022_tests::{HasLogger, Logger}; use expect_test::expect; +use test_log::test; #[salsa::jar(db = Db)] struct Jar(MyInput, MyTracked, final_result, intermediate_result);