Skip to content

Commit aaec038

Browse files
committed
Don't span migrating logs when running tests
We run these all the way from 0 to 29 and back when running tests, which causes quite a lot of output. This changes the output to `trace` in tests, and changes the default logging to only show `debug` and above.
1 parent 843531f commit aaec038

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

.env.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
DOCSRS_PREFIX=ignored/cratesfyi-prefix
22
DOCSRS_DATABASE_URL=postgresql://cratesfyi:password@localhost:15432
3-
DOCSRS_LOG=docs_rs,rustwide=info
3+
DOCSRS_LOG=docs_rs=debug,rustwide=info
44
AWS_ACCESS_KEY_ID=cratesfyi
55
AWS_SECRET_ACCESS_KEY=secret_key
66
S3_ENDPOINT=http://localhost:9000

src/db/migrate.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Database migrations
22
3-
use log::info;
3+
use log::{log, Level};
44
use postgres::{Client, Error as PostgresError, Transaction};
55
use schemamama::{Migration, Migrator, Version};
66
use schemamama_postgres::{PostgresAdapter, PostgresMigration};
@@ -27,17 +27,30 @@ macro_rules! migration {
2727
$description.to_owned()
2828
}
2929
}
30+
3031
impl PostgresMigration for Amigration {
3132
fn up(&self, transaction: &mut Transaction) -> Result<(), PostgresError> {
32-
info!(
33+
let level = if cfg!(test) {
34+
Level::Trace
35+
} else {
36+
Level::Info
37+
};
38+
log!(
39+
level,
3340
"Applying migration {}: {}",
3441
self.version(),
3542
self.description()
3643
);
3744
transaction.batch_execute($up).map(|_| ())
3845
}
3946
fn down(&self, transaction: &mut Transaction) -> Result<(), PostgresError> {
40-
info!(
47+
let level = if cfg!(test) {
48+
Level::Trace
49+
} else {
50+
Level::Info
51+
};
52+
log!(
53+
level,
4154
"Removing migration {}: {}",
4255
self.version(),
4356
self.description()

0 commit comments

Comments
 (0)