From dbb47752eba8f14fe74e330941887150488ad779 Mon Sep 17 00:00:00 2001 From: Fumiaki Kinoshita Date: Mon, 8 Aug 2022 16:24:55 +0900 Subject: [PATCH] add a test --- herp-logger.cabal | 12 ++++++++++++ tests/stdout.hs | 28 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/stdout.hs diff --git a/herp-logger.cabal b/herp-logger.cabal index cc3f08f..3840361 100644 --- a/herp-logger.cabal +++ b/herp-logger.cabal @@ -86,3 +86,15 @@ library , unix-time , unordered-containers default-language: Haskell2010 + +test-suite stdout + type: exitcode-stdio-1.0 + main-is: stdout.hs + hs-source-dirs: + tests + build-depends: + base >=4.7 && <5 + , herp-logger + , fast-logger + , mtl + default-language: Haskell2010 diff --git a/tests/stdout.hs b/tests/stdout.hs new file mode 100644 index 0000000..bd08123 --- /dev/null +++ b/tests/stdout.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE OverloadedLists #-} +{-# LANGUAGE OverloadedLabels #-} +{-# LANGUAGE OverloadedStrings #-} +module Main where + +import Control.Concurrent (threadDelay) +import Control.Exception (bracket) +import Control.Monad.Reader +import Herp.Logger as Logger +import Herp.Logger.StdoutTransport +import System.Log.FastLogger.LoggerSet as LS + +main :: IO () +main = bracket (LS.newStdoutLoggerSet 4096) LS.rmLoggerSet $ \loggerSet -> do + + logger <- Logger.new 1 Debug [stdoutTransport loggerSet Debug] + + flip runReaderT logger $ do + logM [ #debug, "debug" ] + logM [ #info, "hello, world", "key" .= ("value" :: String) ] + logM [ #notice, "lorem ipsum" ] + logM [ #warn, "lorem ipsum" ] + logM [ #error, "lorem ipsum" ] + logM [ #crit, "lorem ipsum" ] + logM [ #alert, "lorem ipsum" ] + logM [ #emerg, "lorem ipsum" ] + + loggerCleanup logger \ No newline at end of file