Skip to content

Commit

Permalink
feat: show PostgREST version in the logs
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenceisla authored Jul 7, 2023
1 parent add10bd commit e752224
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/PostgREST/AppState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ internalConnectionWorker appState = work
where
work = do
AppConfig{..} <- getConfig appState
logWithZTime appState $ "Starting PostgREST " <> T.decodeUtf8 prettyVersion <> "..."
logWithZTime appState "Attempting to connect to the database..."
connected <- establishConnection appState
case connected of
Expand Down
4 changes: 3 additions & 1 deletion test/io/postgrest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def run(
host=None,
wait_for_readiness=True,
no_pool_connection_available=False,
no_startup_stdout=True,
):
"Run PostgREST and yield an endpoint that is ready for connections."

Expand Down Expand Up @@ -104,7 +105,8 @@ def run(
if wait_for_readiness:
wait_until_ready(adminurl + "/ready")

process.stdout.read()
if no_startup_stdout:
process.stdout.read()

if no_pool_connection_available:
sleep_pool_connection(baseurl, 10)
Expand Down
12 changes: 12 additions & 0 deletions test/io/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,3 +1039,15 @@ def test_get_pgrst_version_with_keyval_connection_string(defaultenv):
"postgrest/", "PostgREST "
)
assert response.text == version


def test_log_postgrest_version(defaultenv):
"Should show the PostgREST version in the logs"

with run(env=defaultenv, no_startup_stdout=False) as postgrest:
version = postgrest.session.head("/").headers["Server"].split("/")[1]

assert (
"Starting PostgREST %s..." % version
in postgrest.process.stdout.readline().decode()
)

0 comments on commit e752224

Please sign in to comment.