fast-logger 0.2.0 → 0.2.1
raw patch · 2 files changed
+19/−17 lines, 2 filesdep +unix-timePVP ok
version bump matches the API change (PVP)
Dependencies added: unix-time
API changes (from Hackage documentation)
+ System.Log.FastLogger.Date: instance Eq DateCache
+ System.Log.FastLogger.Date: instance Show DateCache
Files
- System/Log/FastLogger/Date.hs +13/−12
- fast-logger.cabal +6/−5
System/Log/FastLogger/Date.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP #-}+{-# LANGUAGE CPP, OverloadedStrings #-} module System.Log.FastLogger.Date ( ZonedDate@@ -9,16 +9,16 @@ import Control.Applicative import Data.ByteString (ByteString)-import qualified Data.ByteString.Char8 as BS import Data.IORef+#if WINDOWS+import qualified Data.ByteString.Char8 as BS import Data.Time import System.Locale-#if WINDOWS #define TIME UTCTime #define GETTIME getCurrentTime #else+import Data.UnixTime import System.Posix (EpochTime, epochTime)-import Data.Time.Clock.POSIX #define TIME EpochTime #define GETTIME epochTime #endif@@ -27,9 +27,9 @@ type ZonedDate = ByteString data DateCache = DateCache {- unixTime :: !TIME+ timeKey :: !TIME , zonedDate :: !ZonedDate- }+ } deriving (Eq, Show) -- | Reference to the 'ZonedDate' cache. newtype DateRef = DateRef (IORef DateCache)@@ -39,7 +39,7 @@ getDate (DateRef ref) = do newEt <- GETTIME cache <- readIORef ref- let oldEt = unixTime cache+ let oldEt = timeKey cache if oldEt == newEt then return $ zonedDate cache else do@@ -48,15 +48,16 @@ return $ zonedDate newCache newDate :: TIME -> IO DateCache+#if WINDOWS newDate et = DateCache et . format <$> toZonedTime et where- toZonedTime = utcToLocalZonedTime . toUTC-#if WINDOWS- toUTC = id+ format = BS.pack . formatTime defaultTimeLocale "%d/%b/%Y:%T %z"+ toZonedTime = utcToLocalZonedTime #else- toUTC = posixSecondsToUTCTime . realToFrac+newDate et = return $ DateCache et $ toZonedTime et+ where+ toZonedTime = formatUnixTime "%d/%b/%Y:%T %z" . fromEpochTime #endif- format = BS.pack . formatTime defaultTimeLocale "%d/%b/%Y:%T %z" -- | Initializing the 'ZonedDate' cache. dateInit :: IO DateRef
fast-logger.cabal view
@@ -1,5 +1,5 @@ Name: fast-logger-Version: 0.2.0+Version: 0.2.1 Author: Kazu Yamamoto <kazu@iij.ad.jp> Maintainer: Kazu Yamamoto <kazu@iij.ad.jp> License: BSD3@@ -19,13 +19,14 @@ , bytestring , directory , filepath- , old-locale , text- , time if os(windows)- cpp-options: -DWINDOWS+ Cpp-Options: -DWINDOWS+ Build-Depends: old-locale+ , time else- build-depends: unix+ Build-Depends: unix+ , unix-time Source-Repository head Type: git Location: git://github.com/kazu-yamamoto/logger.git