summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md6
-rw-r--r--src/System/Logger/Backend/Handle.hs10
-rw-r--r--src/System/Logger/Logger/Internal.hs13
-rw-r--r--src/System/Logger/Types.hs13
-rw-r--r--yet-another-logger.cabal4
5 files changed, 44 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0973697..58d4aef 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+0.2.3
+=====
+
+* Fix semantically invalid default NFData instance when build with
+ deepseq <1.4.
+
0.2.2
=====
diff --git a/src/System/Logger/Backend/Handle.hs b/src/System/Logger/Backend/Handle.hs
index 680ae1c..569f033 100644
--- a/src/System/Logger/Backend/Handle.hs
+++ b/src/System/Logger/Backend/Handle.hs
@@ -25,6 +25,7 @@
-- Stability: experimental
--
+{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveDataTypeable #-}
@@ -61,6 +62,10 @@ module System.Logger.Backend.Handle
, handleBackend_
) where
+#ifndef MIN_VERSION_deepseq
+#define MIN_VESION_deepseq(a,b,c) 1
+#endif
+
import Configuration.Utils hiding (Lens', Error)
import Configuration.Utils.Validation
@@ -171,7 +176,12 @@ handleBackendConfigColor = lens _handleBackendConfigColor $ \a b → a { _handle
handleBackendConfigHandle ∷ Lens' HandleBackendConfig LoggerHandleConfig
handleBackendConfigHandle = lens _handleBackendConfigHandle $ \a b → a { _handleBackendConfigHandle = b }
+#if MIN_VERSION_deepseq(1,4,0)
instance NFData HandleBackendConfig
+#else
+instance NFData HandleBackendConfig where
+ rnf (HandleBackendConfig a0 a1) = rnf a0 `seq` rnf a1
+#endif
defaultHandleBackendConfig ∷ HandleBackendConfig
defaultHandleBackendConfig = HandleBackendConfig
diff --git a/src/System/Logger/Logger/Internal.hs b/src/System/Logger/Logger/Internal.hs
index c828d72..c60275e 100644
--- a/src/System/Logger/Logger/Internal.hs
+++ b/src/System/Logger/Logger/Internal.hs
@@ -31,6 +31,7 @@
-- module as an example and starting point.
--
+{-# LANGUAGE CPP #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
@@ -78,6 +79,10 @@ module System.Logger.Logger.Internal
, runLogT
) where
+#ifndef MIN_VERSION_deepseq
+#define MIN_VESION_deepseq(a,b,c) 1
+#endif
+
import Configuration.Utils hiding (Lens', Error)
import Control.Concurrent (threadDelay)
@@ -189,7 +194,15 @@ loggerConfigExceptionWait = lens _loggerConfigExceptionWait $ \a b → a { _logg
loggerConfigExitTimeout ∷ Lens' LoggerConfig (Maybe Natural)
loggerConfigExitTimeout = lens _loggerConfigExitTimeout $ \a b → a { _loggerConfigExitTimeout = b }
+#if MIN_VERSION_deepseq(1,4,0)
instance NFData LoggerConfig
+#else
+instance NFData Natural where
+ rnf a = a `seq` ()
+instance NFData LoggerConfig where
+ rnf (LoggerConfig a0 a1 a2 a3 a4 a5 a6) =
+ rnf a0 `seq` rnf a1 `seq` rnf a2 `seq` rnf a3 `seq` rnf a4 `seq` rnf a5 `seq` rnf a6
+#endif
-- | Default Logger configuration
--
diff --git a/src/System/Logger/Types.hs b/src/System/Logger/Types.hs
index a275b5a..bd63808 100644
--- a/src/System/Logger/Types.hs
+++ b/src/System/Logger/Types.hs
@@ -25,6 +25,7 @@
-- Stability: experimental
--
+{-# LANGUAGE CPP #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE LambdaCase #-}
@@ -89,6 +90,10 @@ module System.Logger.Types
) where
+#ifndef MIN_VERSION_deepseq
+#define MIN_VESION_deepseq(a,b,c) 1
+#endif
+
import Configuration.Utils hiding (Lens, Lens', Error)
import Control.DeepSeq
@@ -312,8 +317,16 @@ logMsgScope = lens _logMsgScope $ \a b → a { _logMsgScope = b }
logMsgTime ∷ Lens' (LogMessage a) TimeSpec
logMsgTime = lens _logMsgTime $ \a b → a { _logMsgTime = b }
+#if MIN_VERSION_deepseq(1,4,0)
instance NFData TimeSpec
instance NFData a ⇒ NFData (LogMessage a)
+#else
+instance NFData TimeSpec where
+ rnf (TimeSpec a0 a1) = rnf a0 `seq` rnf a1
+instance NFData a ⇒ NFData (LogMessage a) where
+ rnf (LogMessage a0 a1 a2 a3) =
+ rnf a0 `seq` rnf a1 `seq` rnf a2 `seq` rnf a3
+#endif
-- | This is given to logger when it is created. It formats and delivers
-- individual log messages synchronously. The backend is called once for each
diff --git a/yet-another-logger.cabal b/yet-another-logger.cabal
index e712f88..2cc26fd 100644
--- a/yet-another-logger.cabal
+++ b/yet-another-logger.cabal
@@ -1,5 +1,5 @@
Name: yet-another-logger
-Version: 0.2.2
+Version: 0.2.3
Synopsis: Yet Another Logger
Description:
A logging framework written with flexibility and performance
@@ -73,7 +73,7 @@ source-repository this
type: git
location: https://github.com/alephcloud/hs-yet-another-logger
branch: master
- tag: 0.2.2
+ tag: 0.2.3
Library
default-language: Haskell2010