fix: remove red herring warp logs on default log-level
The logs added on e95e815483 are red
herrings under normal operation.
This moves them to `log-level=debug` and removes "error" from the
message prefix.
Fixes https://github.com/PostgREST/postgrest/issues/4799
This commit is contained in:
committed by
Steve Chavez
parent
9230f3f49a
commit
fb31654277
@@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file. From versio
|
|||||||
|
|
||||||
- Log host, port and pg version of listener database connection by @mkleczek in #4617 #4618
|
- Log host, port and pg version of listener database connection by @mkleczek in #4617 #4618
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Remove red herring warp logs on default log-level, only emit them on `log-level=debug` by @steve-chavez in #4799
|
||||||
|
|
||||||
## [14.8] - 2026-04-03
|
## [14.8] - 2026-04-03
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ run appState = do
|
|||||||
onWarpException :: Maybe Wai.Request -> SomeException -> IO ()
|
onWarpException :: Maybe Wai.Request -> SomeException -> IO ()
|
||||||
onWarpException _ ex =
|
onWarpException _ ex =
|
||||||
when (shouldDisplayException ex) $
|
when (shouldDisplayException ex) $
|
||||||
observer $ WarpErrorObs $ show ex
|
observer $ WarpServerObs $ show ex
|
||||||
|
|
||||||
-- Similar to wai defaultShouldDisplayException in
|
-- Similar to wai defaultShouldDisplayException in
|
||||||
-- https://github.com/yesodweb/wai//blob/8c3882c60f6abe043889fc20c7efd3fa9747fa4a/warp/Network/Wai/Handler/Warp/Settings.hs#L251-L258
|
-- https://github.com/yesodweb/wai//blob/8c3882c60f6abe043889fc20c7efd3fa9747fa4a/warp/Network/Wai/Handler/Warp/Settings.hs#L251-L258
|
||||||
|
|||||||
@@ -116,6 +116,9 @@ observationLogger loggerState logLevel obs = case obs of
|
|||||||
o@(JwtCacheLookup _) ->
|
o@(JwtCacheLookup _) ->
|
||||||
when (logLevel >= LogDebug) $ do
|
when (logLevel >= LogDebug) $ do
|
||||||
logWithZTime loggerState $ observationMessage o
|
logWithZTime loggerState $ observationMessage o
|
||||||
|
o@(WarpServerObs _) ->
|
||||||
|
when (logLevel >= LogDebug) $ do
|
||||||
|
logWithZTime loggerState $ observationMessage o
|
||||||
o ->
|
o ->
|
||||||
logWithZTime loggerState $ observationMessage o
|
logWithZTime loggerState $ observationMessage o
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ data Observation
|
|||||||
| JwtCacheLookup Bool
|
| JwtCacheLookup Bool
|
||||||
| JwtCacheEviction
|
| JwtCacheEviction
|
||||||
| TerminationUnixSignalObs Text
|
| TerminationUnixSignalObs Text
|
||||||
| WarpErrorObs Text
|
| WarpServerObs Text
|
||||||
deriving (Generic)
|
deriving (Generic)
|
||||||
|
|
||||||
data ObsFatalError = ServerAuthError | ServerPgrstBug | ServerError42P05 | ServerError08P01
|
data ObsFatalError = ServerAuthError | ServerPgrstBug | ServerError42P05 | ServerError08P01
|
||||||
@@ -167,8 +167,8 @@ observationMessage = \case
|
|||||||
"Evicted entry from JWT cache"
|
"Evicted entry from JWT cache"
|
||||||
TerminationUnixSignalObs signal ->
|
TerminationUnixSignalObs signal ->
|
||||||
"Received termination unix signal " <> signal
|
"Received termination unix signal " <> signal
|
||||||
WarpErrorObs txt ->
|
WarpServerObs txt ->
|
||||||
"Warp server error: " <> txt
|
"Warp server: " <> txt
|
||||||
where
|
where
|
||||||
showMillis :: Double -> Text
|
showMillis :: Double -> Text
|
||||||
showMillis x = toS $ showFFloat (Just 1) x ""
|
showMillis x = toS $ showFFloat (Just 1) x ""
|
||||||
|
|||||||
@@ -55,13 +55,15 @@ def test_openapi_in_big_schema(defaultenv):
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
def test_stackoverflow_is_logged(defaultenv):
|
@pytest.mark.parametrize("level", ["crit", "error", "warn", "info", "debug"])
|
||||||
"Stack overflow errors should be logged with the Warp error message"
|
def test_stackoverflow_is_logged(level, defaultenv):
|
||||||
|
"Stack overflow should be logged with the Warp message only on log-level=debug"
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
**defaultenv,
|
**defaultenv,
|
||||||
"PGRST_DB_SCHEMAS": "apflora",
|
"PGRST_DB_SCHEMAS": "apflora",
|
||||||
"PGRST_DB_ANON_ROLE": "postgrest_test_anonymous",
|
"PGRST_DB_ANON_ROLE": "postgrest_test_anonymous",
|
||||||
|
"PGRST_LOG_LEVEL": level,
|
||||||
}
|
}
|
||||||
|
|
||||||
with run(env=env, wait_max_seconds=30, no_startup_stdout=False) as postgrest:
|
with run(env=env, wait_max_seconds=30, no_startup_stdout=False) as postgrest:
|
||||||
@@ -69,9 +71,15 @@ def test_stackoverflow_is_logged(defaultenv):
|
|||||||
postgrest.session.get("/")
|
postgrest.session.get("/")
|
||||||
|
|
||||||
output = postgrest.read_stdout(nlines=10)
|
output = postgrest.read_stdout(nlines=10)
|
||||||
output.extend(postgrest.read_stdout(nlines=10))
|
for _ in range(3):
|
||||||
|
output.extend(postgrest.read_stdout(nlines=10))
|
||||||
|
|
||||||
assert any("Warp server error: stack overflow" in line for line in output)
|
found = any("Warp server: stack overflow" in line for line in output)
|
||||||
|
|
||||||
|
if level == "debug":
|
||||||
|
assert found
|
||||||
|
else:
|
||||||
|
assert not found
|
||||||
|
|
||||||
|
|
||||||
# See: https://github.com/PostgREST/postgrest/issues/3329
|
# See: https://github.com/PostgREST/postgrest/issues/3329
|
||||||
|
|||||||
Reference in New Issue
Block a user