Create wai log entry with google logging format.
Middleware for wai which create log entry as Google Cloud Platform's Logging service format.
This package is not in hackage yet. So for install it add to stack.yaml
in packages
next:
- location:
git: https://github.com/d61h6k4/wai-logging-effect-google.git
commit: <insert commit here>
and add wai-logging-effect-google
to your cabal
file.
Here example how I use it with wai server on GCP. Additionally here used logging-effect-google. Here google logging handler used to store logs from wai.
app :: Application
app request respond =
case rawPathInfo request of
"/events" ->
events request >>= respond
main :: IO ()
main = do
lgr <- newLogger Debug stdout
env <- newEnv <&> (envScopes .~ ( loggingWriteScope ! pubSubScope)) . (envLogger .~ lgr)
withGoogleLoggingHandler
(defaultBatchingOptions
{ flushMaxDelay = 10 * 1000000
, flushMaxQueueSize = 128
})
env
(Just
("projects/" <> ("test_project_id") <>
("/logs/negotians")))
(Just
((monitoredResource & mrLabels .~
(Just
(monitoredResourceLabels
(HashMap.fromList
([ ( "instanceId"
, ("0000"))
, ("zone", ("eu-west1-c"))]))))) &
mrType .~
(Just "gce_instance")))
Nothing $
\wailogger ->
run 3000 $ loggerMiddleware wailogger $ gzip def $
app
Fork it.
Distributed under BSD license. See LICENSE
for more information.