logging 3.0.1 → 3.0.2
raw patch · 3 files changed
+20/−6 lines, 3 filesdep +time-locale-compat
Dependencies added: time-locale-compat
Files
- Control/Logging.hs +2/−4
- logging.cabal +2/−1
- test/main.hs +16/−1
Control/Logging.hs view
@@ -1,5 +1,4 @@ {-# OPTIONS_GHC -Wall -fno-warn-orphans #-}-{-# LANGUAGE CPP #-} -- | Quick example of how to use this module: --@@ -60,6 +59,7 @@ , setLogLevel , setLogTimeFormat , setDebugSourceRegex+ , LogLevel (..) ) where import Control.Exception.Lifted@@ -73,9 +73,7 @@ import Data.Text as T import Data.Text.Encoding as T import Data.Time-#if !MIN_VERSION_time (1,5,0)-import System.Locale (defaultTimeLocale)-#endif+import Data.Time.Locale.Compat (defaultTimeLocale) import Debug.Trace import Prelude hiding (log) import System.IO.Unsafe
logging.cabal view
@@ -1,5 +1,5 @@ Name: logging-Version: 3.0.1+Version: 3.0.2 Synopsis: Simplified logging in IO for application writers. License-file: LICENSE License: MIT@@ -44,6 +44,7 @@ , time >= 1.4 , monad-control >= 0.3.2.3 , text >= 0.11.3.1+ , time-locale-compat >= 0.1.1.0 , transformers >= 0.3.0.0 , lifted-base >= 0.2.2.0 , pcre-light >= 0.4
test/main.hs view
@@ -11,8 +11,10 @@ main :: IO () main = hspec $ do+ describe "simple logging" $ do- it "logs output" $ (withStdoutLogging :: IO () -> IO ()) $ do++ it "logs output" $ withStdoutLogging $ do log "Hello, world!" warnS "test-suite" "you've been warned" timedLog "Did a good thing" $ threadDelay 100000@@ -20,6 +22,19 @@ threadDelay 100000 >> error "foo" _ <- tryAny $ errorL "Uh oh" return ()++ it "supports setting log levels" $ do+ setLogLevel LevelWarn++ withStdoutLogging $ do+ debugS "Set LogLevel test" "This is an unshown debug message"+ logS "Set LogLevel test" "This is an unshown info message"+ warnS "Set LogLevel test" "This is a shown info message"+ _ <- tryAny $ errorSL "Set LogLevel test" "This is a shown error message"+ return ()++ -- setting the log level back to debug so that following tests run+ setLogLevel LevelDebug it "supports using debug classes" $ do setDebugSourceRegex "foo\\..*"