packages feed

logstash 0.1.0.1 → 0.1.0.2

raw patch · 2 files changed

+75/−56 lines, 2 filesdep ~aesondep ~asyncdep ~bytestring

Dependency ranges changed: aeson, async, bytestring, data-default-class, exceptions, monad-control, mtl, network, resource-pool, resourcet, retry, stm, stm-chans, time, tls, unbounded-delays, unliftio

Files

README.md view
@@ -3,12 +3,13 @@ ![MIT](https://img.shields.io/github/license/mbg/logstash) ![CI](https://github.com/mbg/logstash/workflows/Build/badge.svg?branch=master) ![stackage-nightly](https://github.com/mbg/logstash/workflows/stackage-nightly/badge.svg)+[![logstash](https://img.shields.io/hackage/v/logstash)](https://hackage.haskell.org/package/logstash)  This library implements a client for Logstash in Haskell. The following features are currently supported:  - Connections to Logstash via TCP or TLS (`tcp` input type). - Support for the `json_lines` codec out of the box and custom codecs can be implemented (arbitrary `ByteString` data can be sent across the connections).-- This library can either be used without any logging framework or as a backend for [`monad-logger`](http://hackage.haskell.org/package/monad-logger/).+- This library can either be used without any logging framework, as a backend for [`monad-logger`](http://hackage.haskell.org/package/monad-logger/), or as a backend for [`katip`](http://hackage.haskell.org/package/katip/). - Log messages can either be written synchronously or asynchronously.  For example, to connect to a Logstash server via TCP at `127.0.0.1:5000` (configuration given by `def`) and send a JSON document synchronously with a timeout of 1s and the default retry policy from [`Control.Retry`](https://hackage.haskell.org/package/retry/docs/Control-Retry.html):@@ -124,18 +125,19 @@ The queue is automatically closed when the inner computation returns. The worker threads will continue running until the queue is empty and then terminate. `withLogstashQueue` will not return until all worker threads have returned.  ### Usage with `monad-logger`+[![monad-logger-logstash](https://img.shields.io/hackage/v/monad-logger-logstash)](https://hackage.haskell.org/package/monad-logger-logstash)  The `monad-logger-logstash` package provides convenience functions and types for working with [`monad-logger`](http://hackage.haskell.org/package/monad-logger/).   #### Synchronous logging -The following example demonstrates how to use the `runLogstashLoggerT` function with a TCP connection to Logstash, the default retry policy from [`Control.Retry`](https://hackage.haskell.org/package/retry/docs/Control-Retry.html), a 1s timeout for each attempt, and the `json_lines` codec:+The following example demonstrates how to use the `runLogstashLoggingT` function with a TCP connection to Logstash, the default retry policy from [`Control.Retry`](https://hackage.haskell.org/package/retry/docs/Control-Retry.html), a 1s timeout for each attempt, and the `json_lines` codec:  ```haskell main :: IO () main = do      let ctx = logstashTcp def-    runLogstashLoggerT ctx retryPolicyDefault 1000000 (const stashJsonLine) $ +    runLogstashLoggingT ctx retryPolicyDefault 1000000 (const stashJsonLine) $          logInfoN "Hello World" ``` @@ -143,17 +145,37 @@  #### Asynchronous logging -The `withLogstashLoggerT` function is the analogue of `withLogstashQueue` for `monad-logger`. It performs the same setup as `withLogstashQueue`, but automatically adds all log messages from logging functions to the queue. A minimal example with default settings is:+The `withLogstashLoggingT` function is the analogue of `withLogstashQueue` for `monad-logger`. It performs the same setup as `withLogstashQueue`, but automatically adds all log messages from logging functions to the queue. A minimal example with default settings is:  ```haskell main :: IO () main = do      let ctx = logstashTcp def-    withLogstashLoggerT (defaultLogstashQueueCfg ctx) (const stashJsonLine) [] $ +    withLogstashLoggingT (defaultLogstashQueueCfg ctx) (const stashJsonLine) [] $          logInfoN "Hello World" ``` +While `withLogstashLoggingT` is useful for scenarios where there is a single producer for which log messages should be dispatched asynchronously, we may wish to share the same queue among several producers. For such applications, the `runTBMQueueLoggingT` in combination with `withLogstashQueue` is a better fit:++```haskell+main :: IO ()+main = do +    let ctx = logstashTcp def+    let cfg = defaultLogstashQueueCfg ctx++    withLogstashQueue cfg (const stashJsonLine) [] $ \queue -> do+        thread <- async $ runTBMQueueLoggingT queue $ do+            liftIO $ threadDelay (60*1000*1000)+            logInfoN "I am consumer #2" +        +        runTBMQueueLoggingT queue $ do +            logInfoN "I am consumer #1"++        wait thread+```+ ### Usage with `katip`+[![katip-logstash](https://img.shields.io/hackage/v/katip-logstash)](https://hackage.haskell.org/package/katip-logstash)  The `katip-logstash` package provides convenience functions and types for working with [`katip`](http://hackage.haskell.org/package/katip/).  
logstash.cabal view
@@ -1,59 +1,56 @@-cabal-version: 1.12---- This file has been generated from package.yaml by hpack version 0.33.0.------ see: https://github.com/sol/hpack------ hash: dacbd9edf7d3d77751149456ac269687395f9dc7bb51f53de298d944c8b3dd7c+cabal-version:      1.12+name:               logstash+version:            0.1.0.2+license:            MIT+license-file:       LICENSE+copyright:          Copyright (c) 2021 Michael B. Gale+maintainer:         github@michael-gale.co.uk+author:             Michael B. Gale+homepage:           https://github.com/mbg/logstash#readme+bug-reports:        https://github.com/mbg/logstash/issues+synopsis:           Logstash client library for Haskell+description:+    Please see the README on GitHub at <https://github.com/mbg/logstash#readme> -name:           logstash-version:        0.1.0.1-synopsis:       Logstash client library for Haskell-description:    Please see the README on GitHub at <https://github.com/mbg/logstash#readme>-category:       Network-homepage:       https://github.com/mbg/logstash#readme-bug-reports:    https://github.com/mbg/logstash/issues-author:         Michael B. Gale-maintainer:     m.gale@warwick.ac.uk-copyright:      Copyright (c) 2020 Michael B. Gale-license:        MIT-license-file:   LICENSE-build-type:     Simple+category:           Network+build-type:         Simple extra-source-files:     README.md     ChangeLog.md  source-repository head-  type: git-  location: https://github.com/mbg/logstash+    type:     git+    location: https://github.com/mbg/logstash  library-  exposed-modules:-      Logstash-      Logstash.Connection-      Logstash.TCP-  other-modules:-      Paths_logstash-  hs-source-dirs:-      src-  default-extensions: OverloadedStrings RecordWildCards FlexibleContexts FlexibleInstances-  build-depends:-      aeson-    , async-    , base >=4.7 && <5-    , bytestring-    , data-default-class-    , exceptions-    , monad-control-    , mtl-    , network-    , resource-pool-    , resourcet-    , retry-    , stm-    , stm-chans-    , time-    , tls-    , unbounded-delays-    , unliftio-  default-language: Haskell2010+    exposed-modules:+        Logstash+        Logstash.Connection+        Logstash.TCP++    hs-source-dirs:     src+    other-modules:      Paths_logstash+    default-language:   Haskell2010+    default-extensions:+        OverloadedStrings RecordWildCards FlexibleContexts+        FlexibleInstances++    build-depends:+        aeson <1.6,+        async <2.3,+        base >=4.7 && <5,+        bytestring <0.11,+        data-default-class <0.2,+        exceptions <0.11,+        monad-control <1.1,+        mtl <2.3,+        network <3.2,+        resource-pool <0.3,+        resourcet <1.3,+        retry <0.9,+        stm <2.6,+        stm-chans <3.1,+        time <1.10,+        tls <1.6,+        unbounded-delays <0.2,+        unliftio <0.3