0
haskellにKatip logging libraryを使用することを示す最小限の例はありますか?Katipロギングライブラリの最小例
haskellにKatip logging libraryを使用することを示す最小限の例はありますか?Katipロギングライブラリの最小例
クレジットはJoe Kachmar
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Control.Exception
import Katip
import System.IO (stdout)
type Stack a = KatipContextT IO a
-- `Stack()` is the same thing as `KatipContextT IO()`
-- test :: Stack()
test :: KatipContextT IO()
test = do
$(logTM) InfoS "Hello from Katip!"
$(logTM) InfoS "I can do any kind of `IO` action here with `liftIO`!"
main :: IO()
main = do
handleScribe <- mkHandleScribe ColorIfTerminal stdout InfoS V2
let mkLogEnv = registerScribe "stdout" handleScribe defaultScribeSettings =<< initLogEnv "MyApp" "production"
bracket mkLogEnv closeScribes $ \le -> do
runKatipContextT le (mempty :: LogContexts) mempty test
に行きます