Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/filters/system_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ impl SystemFilter {
b"walsender",
b"archiver",
// Startup / shutdown
b"starting PostgreSQL",
b"database system is starting",
b"database system is ready",
b"database system is shutting down",
b"startup process",
b"shutdown",
b"shut down",
b"listening on ",
// Configuration changes
b"reloading configuration",
b"configuration file",
Expand Down Expand Up @@ -71,6 +73,7 @@ mod test {
(b"Database system is starting up", true),
(b"Reloading configuration file", true),
(b"Creating extension pg_stat_statements", true),
(b"listening on IPv4 address \"127.0.0.1\", port 54316", true),
(b"This is a normal log message", false),
(b"User logged in successfully", false),
];
Expand Down
5 changes: 5 additions & 0 deletions tests/files/system_test.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
2025-08-27 01:24:18.975 EEST [3863217] LOG: starting PostgreSQL 16.10 (Ubuntu 16.10-1.pgdg24.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0, 64-bit
2025-08-27 01:24:18.975 EEST [3863217] LOG: listening on IPv4 address "127.0.0.1", port 54316
2025-08-27 01:24:18.978 EEST [3863217] LOG: listening on Unix socket "/tmp/.s.PGSQL.54316"
2025-08-27 01:24:18.982 EEST [3863221] LOG: database system was shut down at 2025-08-27 01:23:49 EEST
2025-08-27 01:24:18.987 EEST [3863217] LOG: database system is ready to accept connections
17 changes: 17 additions & 0 deletions tests/system.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use assert_cmd::cargo;
use assert_cmd::prelude::*;
use predicates::prelude::PredicateBooleanExt;
use std::process::Command; // Run programs

#[test]
fn simple_log_system() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::new(cargo::cargo_bin!("pgweasel"));

cmd.args(["system", "./tests/files/system_test.log"])
.assert()
.success()
.stdout(
predicates::str::contains("listening").and(predicates::str::contains("was shut down")),
);
Ok(())
}