Skip to content

Instantly share code, notes, and snippets.

@DarinM223
Created February 5, 2023 04:20
Show Gist options
  • Save DarinM223/4d1abe1c7e2ec12bc5ea6d492f83c039 to your computer and use it in GitHub Desktop.
Save DarinM223/4d1abe1c7e2ec12bc5ea6d492f83c039 to your computer and use it in GitHub Desktop.
Logging rich messages in co-log
{-# LANGUAGE OverloadedStrings #-}
import Colog
import Control.Monad.IO.Class (MonadIO)
import Data.Text (Text)
foo :: (WithLog env Message m, MonadIO m) => m ()
foo = do
logWarning "Hello"
logWarning "World"
logTextBoth :: LogAction IO Text
logTextBoth = logTextStdout <> logTextStderr
main :: IO ()
main = do
let action = upgradeMessageAction defaultFieldMap $ cmapM fmtRichMessageDefault logTextBoth
usingLoggerT action foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment