polysemy-log: Polysemy Effects for Logging

[ library, logging ] [ Propose Tags ]
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.0.1, 0.2.1.0, 0.2.2.0, 0.2.2.1, 0.2.2.2, 0.2.2.3, 0.2.2.4, 0.3.0.0, 0.3.0.1, 0.3.0.2, 0.4.0.0, 0.4.1.0, 0.4.2.0, 0.4.3.0, 0.5.0.0, 0.6.0.0, 0.6.0.1, 0.7.0.0, 0.7.1.0, 0.7.2.0, 0.8.0.0, 0.9.0.0, 0.10.0.0, 0.10.0.1 (info)
Change log changelog.md
Dependencies ansi-terminal (>=0.10.3), base (>=4 && <5), polysemy (>=1.5), polysemy-conc (>=0.1.0.0), polysemy-time (>=0.1.1.0), relude (>=0.7), string-interpolate (>=0.2.1), template-haskell, text, time [details]
License BSD-2-Clause-Patent
Copyright 2021 Torsten Schmits
Author Torsten Schmits
Maintainer tek@tryp.io
Category Logging
Home page https://github.com/tek/polysemy-log#readme
Bug tracker https://github.com/tek/polysemy-log/issues
Source repo head: git clone https://github.com/tek/polysemy-log
Uploaded by tek at 2021-09-11T17:54:29Z
Distributions
Reverse Dependencies 12 direct, 13 indirect [details]
Downloads 3036 total (79 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for polysemy-log-0.2.2.4

[back to package description]

Log thrice, debug once.

–– Г. Любенов

About

A common interface for the polysemy logging backend adapters.

An example program using co-log, for the simple logger with predefined formatting and a custom data type:

import Colog (logTextStdout)
import Colog.Polysemy (runLogAction)
import Polysemy (runM)

import Polysemy.Log.Colog (interpretDataLogColog, interpretLogStdout)
import qualified Polysemy.Log.Data.DataLog as DataLog
import Polysemy.Log.Data.DataLog (DataLog)
import qualified Polysemy.Log.Data.Log as Log
import Polysemy.Log.Data.Log (Log)

progSimple ::
  Member Log r =>
  Sem r ()
progSimple = do
  Log.debug "debug"
  Log.warn "warn"

data Message =
  Message {
    severity :: Text,
    message :: Text
  }
  deriving (Eq, Show)

progData ::
  Member (DataLog Message) r =>
  Sem r ()
progData = do
  DataLog.dataLog (Message "warn" "warning!")
  DataLog.local (\ msg@Message{message} -> msg {message = "context: " <> message}) do
    DataLog.dataLog (Message "error" "segfault!")

main :: IO ()
main =
  runM do
    interpretLogStdout progSimple
    runLogAction @IO (contramap message logTextStdout) $ interpretDataLogColog @Message $ progData

For more documentation, please consult Hackage:

Building the Project

The build is defined in nix, supporting flake and legacy nix-build.

With nix-build:

nix-build -A defaultPackage
nix-build -A packages.x86_64-linux.polysemy-log-co

With nix flake:

nix build
nix build '.#polysemy-log-co'

To run all tests:

nix flake check