enable logging of salsa events by default

and add logging to tests
This commit is contained in:
Niko Matsakis 2022-08-07 03:01:39 -04:00
parent 395df47016
commit 323e677182
3 changed files with 8 additions and 3 deletions
components/salsa-2022/src
salsa-2022-tests

View file

@ -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;

View file

@ -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 = "*"

View file

@ -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);