https://github.com/scrive/log
Structured logging solution.
https://github.com/scrive/log
haskell logging scrive
Last synced: 10 months ago
JSON representation
Structured logging solution.
- Host: GitHub
- URL: https://github.com/scrive/log
- Owner: scrive
- License: bsd-3-clause
- Created: 2015-05-07T12:01:18.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T18:44:09.000Z (almost 3 years ago)
- Last Synced: 2024-10-30T00:34:12.836Z (about 1 year ago)
- Topics: haskell, logging, scrive
- Language: Haskell
- Homepage: https://hackage.haskell.org/package/log-base
- Size: 345 KB
- Stars: 35
- Watchers: 34
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# log
[](https://hackage.haskell.org/package/log-base)
[](https://github.com/scrive/log/actions?query=branch%3Amaster)
A set of libraries that provide a way to record structured log messages with
multiple backends.
Supported backends:
* Standard output via
[`log-base`](https://hackage.haskell.org/package/log-base).
* Elasticsearch via
[`log-elasticsearch`](https://hackage.haskell.org/package/log-elasticsearch).
* PostgreSQL via
[`log-postgres`](https://hackage.haskell.org/package/log-postgres).
## Example
A sample usage for logging to both standard output and Elasticsearch:
```haskell
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Log
import Log.Backend.ElasticSearch
import Log.Backend.StandardOutput
main :: IO ()
main = do
let config = defaultElasticSearchConfig
{ esServer = "http://localhost:9200"
, esIndex = "logs"
}
withStdOutLogger $ \stdoutLogger -> do
withElasticSearchLogger config $ \esLogger -> do
runLogT "main" (stdoutLogger <> esLogger) defaultLogLevel $ do
logInfo_ "Hi there"
```