Description
Structured logging solution (base package)
Description
A library that provides a way to record structured log messages. Use this package in conjunction with 'log-elasticsearch' or 'log-postgres', depending on which back end you need.
README.md
log
A set of libraries that provide a way to record structured log messages with multiple backends.
Supported backends:
- Standard output via
log-base
. - Elasticsearch via
log-elasticsearch
. - PostgreSQL via
log-postgres
.
Example
A sample usage for logging to both standard output and Elasticsearch:
{-# 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"