diff --git a/CHANGELOG.md b/CHANGELOG.md index 14a2e1de0..784cd8630 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). + For enabling this, the `admin-server-port` config must be set explictly + A `:/live` endpoint is available for checking if postgrest is running on its port/socket. 200 OK = alive, 503 = dead. + A `:/ready` endpoint is available for checking a correct internal state(the database connection plus the schema cache). 200 OK = ready, 503 = not ready. + - #1988, Add the current user to the request log on stdout - @DavidLindbom, @wolfgangwalther ### Fixed diff --git a/src/PostgREST/Logger.hs b/src/PostgREST/Logger.hs index ba2645d3a..b5bac1cda 100644 --- a/src/PostgREST/Logger.hs +++ b/src/PostgREST/Logger.hs @@ -10,7 +10,8 @@ import qualified Network.Wai.Middleware.RequestLogger as Wai import Network.HTTP.Types.Status (status400, status500) import System.IO.Unsafe (unsafePerformIO) -import PostgREST.Config (LogLevel (..)) +import qualified PostgREST.Auth as Auth +import PostgREST.Config (LogLevel (..)) import Protolude @@ -25,4 +26,5 @@ middleware logLevel = case logLevel of { Wai.outputFormat = Wai.ApacheWithSettings $ Wai.defaultApacheSettings & Wai.setApacheRequestFilter (\_ res -> filterStatus $ Wai.responseStatus res) + & Wai.setApacheUserGetter (fmap encodeUtf8 . Auth.getRole) } diff --git a/test/io/test_io.py b/test/io/test_io.py index e580d9935..0c7c66e64 100644 --- a/test/io/test_io.py +++ b/test/io/test_io.py @@ -856,7 +856,7 @@ def test_log_level(level, has_output, defaultenv): assert response.status_code == 200 if has_output[0]: assert re.match( - r'unknownSocket - - \[.+\] "GET / HTTP/1.1" 200 - "" "python-requests/.+"', + r'unknownSocket - postgrest_test_anonymous \[.+\] "GET / HTTP/1.1" 200 - "" "python-requests/.+"', postgrest.process.stdout.readline().decode(), ) @@ -864,7 +864,7 @@ def test_log_level(level, has_output, defaultenv): assert response.status_code == 404 if has_output[1]: assert re.match( - r'unknownSocket - - \[.+\] "GET /unknown HTTP/1.1" 404 - "" "python-requests/.+"', + r'unknownSocket - postgrest_test_anonymous \[.+\] "GET /unknown HTTP/1.1" 404 - "" "python-requests/.+"', postgrest.process.stdout.readline().decode(), )