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
로 이동