Skip to content

d61h6k4/wai-logging-effect-google

 
 

Repository files navigation

wai-logging-effect-google

Create wai log entry with google logging format.

Middleware for wai which create log entry as Google Cloud Platform's Logging service format.

Installation

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.

Usage example

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 

Development setup

Fork it.

Release History

Meta

Distributed under BSD license. See LICENSE for more information.

About

wai log entry with google logging format.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Haskell 100.0%