co-log-polysemy-formatting: A Polysemy logging effect for high quality (unstructured) logs.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

co-log-polysemy-formatting builds on the co-log-polysemy package, adding terminal colours, log severity, timestamps, callers, thread ids, and a flexible log format with good defaults. It also allows you to use the formatting library for formatting your log messages.


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.1.0, 0.1.1.0
Change log CHANGELOG.md
Dependencies ansi-terminal (>=0.10.3 && <0.11), base (>=4.11.0.0 && <5), co-log (>=0.4.0.1 && <0.5), co-log-core (>=0.2.1.1 && <0.3), co-log-polysemy (>=0.0.1.1 && <0.1), co-log-polysemy-formatting, formatting (>=7.1.0 && <7.2), polysemy (>=1.3.0.0 && <1.6), polysemy-plugin (>=0.2.4.0 && <0.3), text (>=0.11.0.8 && <1.3), time (>=1.8.0.2 && <1.10) [details]
License BSD-3-Clause
Copyright 2020 Alex Chapman
Author Alex Chapman
Maintainer alex@farfromthere.net
Category Logging
Home page https://github.com/AJChapman/co-log-polysemy-formatting#readme
Bug tracker https://github.com/AJChapman/co-log-polysemy-formatting/issues
Source repo head: git clone https://github.com/AJChapman/co-log-polysemy-formatting
Uploaded by AlexChapman at 2020-12-10T07:04:27Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for co-log-polysemy-formatting-0.1.1.0

[back to package description]

co-log-polysemy-formatting Build Status Hackage

co-log-polysemy-formatting gives you a Polysemy logging effect for high quality (unstructured) logs.

It does this by tying together several excellent packages:

To get started, see the haddock documentation.

Output format

The output format is customisable, but by default it includes:

example output

The colours show up if your terminal supports them, otherwise it will fall back to greyscale, including if you pipe the output to a file.

formatting messages

Our logging functions, e.g. logInfo, take a formatting formatter rather than a String/Text/etc. This makes it quick and easy to build your log messages from whatever type you have at hand, and still allows you to directly log string literals thanks to the OverloadedStrings language extension:

{-# LANGUAGE OverloadedStrings #-}

myString :: String
myString = "this is my string"

myStrictText :: Data.Text.Text
myStrictText = "this is my strict text"

myLazyText :: Data.Text.Lazy.Text
myLazyText = "this is my lazy text"

-- These will all work:
logInfo "a string literal"
logInfo string myString
logInfo stext myStrictText
logInfo text myLazyText
logInfo (string % ", " % stext % ", " % text) myString myStrictText myLazyText

-- And logging structures is easy too:
data Person = Person { personName :: Text, personAge :: Int }

myPerson :: Person
myPerson = Person "Dave" 16

logInfo ("The person's name is " % accessed personName text <> ", and their age is " % accessed personAge int) myPerson

-- Or with lenses
data Person' = Person' { _personName :: Text, _personAge :: Int }
makeLenses ''Person'

myPerson' :: Person'
myPerson' = Person' "Dave" 16

logInfo ("The person's name is " % viewed personName text <> ", and their age is " % viewed personAge int) myPerson'

Why not just use co-log-polysemy?

co-log-polysemy is a generic logging effect that leaves many decisions up to you, such as your logging format and your logging message type. But if you want something that just works, with good defaults, then co-log-polysemy-formatting will get you there faster. And you're still using co-log-polysemy under the hood -- we even re-export some of its functions for you -- we've just added a few features on top.