log 0.9.0.0 → 0.9.0.1
raw patch · 4 files changed
+167/−4 lines, 4 filesdep +ekgdep +hpqtypesdep +text-showdep ~basedep ~log-basedep ~log-elasticsearch
Dependencies added: ekg, hpqtypes, text-show, transformers-base
Dependency ranges changed: base, log-base, log-elasticsearch, log-postgres
Files
- CHANGELOG.md +40/−0
- README.md +38/−0
- bench/Bench.hs +65/−0
- log.cabal +24/−4
+ CHANGELOG.md view
@@ -0,0 +1,40 @@+# log-0.9.0.0 (2017-05-04)+* Updated the Elasticsearch back-end to work with bloodhound-0.14.0.0 (#30).+* The following modules are now deprecated: Log.Backend.ElasticSearch,+ Log.Backend.ElasticSearch.Internal,+ Log.Backend.ElasticSearch.Lens. Use V1/V5 variants directly (#30).++# log-0.8 (2017-03-16)+* Added a few MTL class instances (#28).+* Made ElasticSearchConfig an abstract type (#27).+* Added support for HTTPS and basic auth to log-elasticsearch (#26).++# log-0.7 (2016-11-25)+* Split into four libraries (log, log-base, log-postgres,+ log-elasticsearch).+* Improved documentation (#22).+* Implement 'toEncoding' directly in 'ToJSON' instances (#21).++# log-0.6 (2016-11-22)+* Moved 'withLogger' to 'Log.Internal.Logger'.++# log-0.5.7 (2016-11-22)+* Remove the dependency on 'cond'.+* Fix formatting in 'mkBulkLogger' haddocks (#16).+* Generalise the types of 'logAttention', 'logInfo' and 'logTrace'+ (#17).++# log-0.5.5 (2016-11-16)+* Add an in-memory logging backend for testing (#13).+* Fix the deprecation message for stdout logger.++# log-0.5.4 (2016-10-21)+* New logger creation API, which is harder to misuse.+* Remove the use of finalisers in favour of the new logger API.+* Fix a JSON serialisation issue affecting the Elasticsearch back-end.+* Make the Elasticsearch back-end compatible with Elasticsearch 1.x.+* Fix a synchronisation issue affecting the Elasticsearch back-end.+* Add a test suite and Travis-based CI.++# log-0.1.0+* Initial version.
+ README.md view
@@ -0,0 +1,38 @@+# log [](https://hackage.haskell.org/package/log) [](http://travis-ci.org/scrive/log)++A library that provides a way to record structured log messages with+multiple back ends.++Supported back ends:++* Standard output+* Elasticsearch+* PostgreSQL++The `log` library provides Elasticsearch and PostgreSQL back ends. If+you only need one of those, use `log-base` and `log-elasticsearch` or+`log-postgres`.++## Example++```haskell+{-# LANGUAGE OverloadedStrings #-}++module Main where++import Log+import Log.Backend.ElasticSearch.V5++import System.Random++main :: IO ()+main = do+ let config = defaultElasticSearchConfig {+ esServer = "http://localhost:9200",+ esIndex = "logs",+ esMapping = "log"+ }+ withElasticSearchLogger config randomIO $ \logger ->+ runLogT "main" logger $ do+ logTrace_ "foo"+```
+ bench/Bench.hs view
@@ -0,0 +1,65 @@+module Main where++import Log+import Log.Backend.ElasticSearch.V5+import Log.Backend.PostgreSQL++import Control.Concurrent+import Control.Monad+import Control.Monad.Base+import Control.Monad.IO.Class+import Database.PostgreSQL.PQTypes+import Data.Monoid+import System.Environment+import System.Random+import TextShow++import qualified Data.Text as T+import qualified System.Remote.Monitoring as EKG++-- Usage:+--+-- 1. (Optional) Start elasticsearch/postgres+-- 2. Run the benchmark exe with the appropriate argument ('postgres'/'elastic').+-- 3. Open htop and/or localhost:8000 in the browser+-- 4. Stop elasticsearch/postgres+-- 5. Observe the memory allocation behaviour.++main :: IO ()+main = do+ void $ EKG.forkServer "localhost" 8000+ args <- getArgs+ case args of+ ["postgres"] -> benchPostgres defConnString+ ["postgres", connString] -> benchPostgres (T.pack connString)+ ["elastic"] -> benchElastic+ _ -> benchElastic++defConnString :: T.Text+defConnString = "postgresql://user:password@localhost/log-postgresql-bench"++benchPostgres :: T.Text -> IO ()+benchPostgres connString = do+ putStrLn "postgres"+ ConnectionSource connSource <- poolSource def { csConnInfo = connString } 1 10 1+ withPgLogger connSource $+ \logger -> forever $ benchLogger logger++benchElastic :: IO ()+benchElastic = do+ putStrLn "elastic"+ let config = defaultElasticSearchConfig+ withElasticSearchLogger config randomIO $+ \logger -> forever $ benchLogger logger+++benchLogger :: (MonadIO m, MonadTime m, MonadBase IO m) => Logger -> m ()+benchLogger logger= do+ liftIO $ putStrLn "writing 100 000 log messages..."++ runLogT "log-bench-elasticsearch" logger $+ forM_ [0..10000] $ \(i :: Int) ->+ logTrace_ ("kaboozle kaboozle kaboozle kaboozle kaboozle " <> showt i)++ liftIO $ putStrLn "sleeping for 1 s..."+ liftIO $ threadDelay 1000000 {- 1 sec -}
log.cabal view
@@ -1,5 +1,5 @@ name: log-version: 0.9.0.0+version: 0.9.0.1 synopsis: Structured logging solution with multiple backends description: A library that provides a way to record structured@@ -25,6 +25,7 @@ category: System build-type: Simple cabal-version: >=1.10+extra-source-files: CHANGELOG.md, README.md tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2 Source-repository head@@ -53,9 +54,9 @@ Log.Monad build-depends: base <5,- log-base >= 0.7 && < 0.9,- log-elasticsearch >= 0.9 && < 0.10,- log-postgres >= 0.7 && < 0.9+ log-base >= 0.7.1.1 && < 0.9,+ log-elasticsearch >= 0.9.0.1 && < 0.10,+ log-postgres >= 0.7.0.1 && < 0.9 hs-source-dirs: src @@ -112,3 +113,22 @@ default-extensions: BangPatterns , OverloadedStrings , RecordWildCards++benchmark log-bench+ type: exitcode-stdio-1.0+ build-depends: base,+ ekg,+ log,+ hpqtypes,+ random,+ text,+ text-show,+ transformers,+ transformers-base+ hs-source-dirs: bench+ main-is: Bench.hs+ ghc-options: -Wall -threaded "-with-rtsopts=-T -sstderr"+ default-language: Haskell2010+ default-extensions: OverloadedStrings,+ FlexibleContexts,+ ScopedTypeVariables