katip-logstash 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+63/−46 lines, 3 filesdep ~aesondep ~katipdep ~logstash
Dependency ranges changed: aeson, katip, logstash, retry, stm, stm-chans, text, transformers, unliftio
Files
- ChangeLog.md +3/−0
- README.md +27/−5
- katip-logstash.cabal +33/−41
ChangeLog.md view
@@ -1,5 +1,8 @@ # Changelog for logstash +## v0.1.0.1++- Fixes a bug which caused `LogstashConnection`s from a `LogstashPool` to not get released properly in `runLogstashPool` ## v0.1 - First release with support for connecting to `tcp` (incl. TLS) Logstash inputs and the `json_lines` codec.
README.md view
@@ -3,12 +3,13 @@   +[](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`+[](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`+[](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/).
katip-logstash.cabal view
@@ -1,49 +1,41 @@-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: 76f4ba122c69b7c3a30388131525e5bde7fc8f73d66194b90cc0b6de83216703+cabal-version: 1.12+name: katip-logstash+version: 0.1.0.1+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 backend for katip.+description:+ Please see the README on GitHub at <https://github.com/mbg/logstash#readme> -name: katip-logstash-version: 0.1.0.0-synopsis: Logstash backend for katip.-description: Please see the README on GitHub at <https://github.com/mbg/logstash#readme>-category: Logging-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: Logging+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:- Katip.Scribes.Logstash- other-modules:- Paths_katip_logstash- hs-source-dirs:- src- default-extensions: RecordWildCards OverloadedStrings- build-depends:- aeson- , base >=4.7 && <5- , katip- , logstash- , retry- , stm- , stm-chans- , text- , transformers- , unliftio- default-language: Haskell2010+ exposed-modules: Katip.Scribes.Logstash+ hs-source-dirs: src+ other-modules: Paths_katip_logstash+ default-language: Haskell2010+ default-extensions: RecordWildCards OverloadedStrings+ build-depends:+ aeson <1.6,+ base >=4.7 && <5,+ katip <0.9,+ logstash <0.2,+ retry <0.9,+ stm <2.6,+ stm-chans <3.1,+ text <1.3,+ transformers <0.6,+ unliftio <0.3