polysemy-log: Polysemy effects for logging

[ library, logging ] [ Propose Tags ]

See https://hackage.haskell.org/package/polysemy-log/docs/Polysemy-Log.html


[Skip to Readme]
Versions [RSS] [faq] 0.1.0.0, 0.2.0.0, 0.2.0.1, 0.2.1.0, 0.2.2.0, 0.2.2.1
Change log Changelog.md
Dependencies ansi-terminal, base (==4.*), polysemy (==1.5.*), polysemy-conc (>=0.1.0.0 && <0.2), polysemy-time (>=0.1.1.0 && <0.2), relude (>=0.7 && <1.2), string-interpolate, 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-04-06T19:51:07Z
Distributions NixOS:0.2.2.1
Downloads 295 total (22 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user
Build status unknown [no reports yet]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Candidates


Readme for polysemy-log-0.2.2.1

[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