Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
fumieval committed Aug 8, 2022
1 parent 759b440 commit dbb4775
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
12 changes: 12 additions & 0 deletions herp-logger.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 28 additions & 0 deletions tests/stdout.hs
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dbb4775

Please sign in to comment.