Created
February 5, 2023 04:20
-
-
Save DarinM223/4d1abe1c7e2ec12bc5ea6d492f83c039 to your computer and use it in GitHub Desktop.
Logging rich messages in co-log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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