Skip to content

feat: add query_log_stdout config for pgcat-style query logging#1015

Merged
levkk merged 3 commits into
pgdogdev:mainfrom
marcomicera:query_log_stdout
May 28, 2026
Merged

feat: add query_log_stdout config for pgcat-style query logging#1015
levkk merged 3 commits into
pgdogdev:mainfrom
marcomicera:query_log_stdout

Conversation

@marcomicera
Copy link
Copy Markdown
Contributor

Summary

Adds a query_log_stdout general config option that logs every query to stdout in pgcat-style format: [pool: db][user: user] query.

  • Configurable via pgdog.toml or PGDOG_QUERY_LOG_STDOUT
  • Defaults to false
  • Logs at the start of query parsing so queries are captured even when the parser is bypassed

Test plan

  • Run pgdog with query_log_stdout = true and confirm queries appear in logs

Log every query to stdout when enabled via pgdog.toml or
PGDOG_QUERY_LOG_STDOUT, using format [pool: db][user: user] query
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 28, 2026

CLA assistant check
All committers have signed the CLA.

@marcomicera marcomicera changed the title feat: add query_log_stdout config for pgcat-style query logging feat: add query_log_stdout config for pgcat-style query logging May 28, 2026
@marcomicera marcomicera marked this pull request as ready for review May 28, 2026 09:56
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

❌ Patch coverage is 67.85714% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...c/frontend/client/query_engine/query_log_stdout.rs 33.33% 8 Missing ⚠️
pgdog/src/frontend/client/mod.rs 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@marcomicera
Copy link
Copy Markdown
Contributor Author

Adding tests to cover these 6 missing lines... 👨‍💻

Comment thread pgdog-config/src/general.rs Outdated
Comment thread pgdog/src/frontend/router/parser/query/mod.rs Outdated
Put the query first and append database/user metadata at the end
(`query [database: db, user: user]`) instead of the pgcat-style prefix.
Also rename "pool" to "database" in the suffix for consistency.
Load query_log_stdout once per request in Client::buffer and log via
QueryEngine before parsing, so queries are logged even when the parser
is bypassed (e.g. query_parser = off).
@marcomicera marcomicera requested a review from levkk May 28, 2026 15:59
Copy link
Copy Markdown
Collaborator

@levkk levkk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Let's let CI run but otherwise, good to go.

@levkk levkk merged commit 642ba9c into pgdogdev:main May 28, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants