commit ghc-wai-logger for openSUSE:Factory
Hello community, here is the log from the commit of package ghc-wai-logger for openSUSE:Factory checked in at 2016-04-30 23:30:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-wai-logger (Old) and /work/SRC/openSUSE:Factory/.ghc-wai-logger.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "ghc-wai-logger" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-wai-logger/ghc-wai-logger.changes 2016-01-22 01:08:18.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-wai-logger.new/ghc-wai-logger.changes 2016-04-30 23:30:53.000000000 +0200 @@ -1,0 +2,5 @@ +Tue Apr 26 09:22:36 UTC 2016 - mimi.vx@gmail.com + +- update to 2.2.7 + +------------------------------------------------------------------- Old: ---- wai-logger-2.2.5.tar.gz New: ---- wai-logger-2.2.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-wai-logger.spec ++++++ --- /var/tmp/diff_new_pack.CKW01b/_old 2016-04-30 23:30:53.000000000 +0200 +++ /var/tmp/diff_new_pack.CKW01b/_new 2016-04-30 23:30:53.000000000 +0200 @@ -21,7 +21,7 @@ %bcond_with tests Name: ghc-wai-logger -Version: 2.2.5 +Version: 2.2.7 Release: 0 Summary: A logging system for WAI License: MIT @@ -34,12 +34,10 @@ BuildRequires: ghc-Cabal-devel BuildRequires: ghc-rpm-macros # Begin cabal-rpm deps: -BuildRequires: ghc-auto-update-devel BuildRequires: ghc-blaze-builder-devel BuildRequires: ghc-byteorder-devel BuildRequires: ghc-bytestring-devel BuildRequires: ghc-case-insensitive-devel -BuildRequires: ghc-easy-file-devel BuildRequires: ghc-fast-logger-devel BuildRequires: ghc-http-types-devel BuildRequires: ghc-network-devel ++++++ wai-logger-2.2.5.tar.gz -> wai-logger-2.2.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wai-logger-2.2.5/Network/Wai/Logger/Apache.hs new/wai-logger-2.2.7/Network/Wai/Logger/Apache.hs --- old/wai-logger-2.2.5/Network/Wai/Logger/Apache.hs 2016-01-13 08:28:24.000000000 +0100 +++ new/wai-logger-2.2.7/Network/Wai/Logger/Apache.hs 2016-04-18 07:47:40.000000000 +0200 @@ -14,7 +14,6 @@ import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as BS -import Data.CaseInsensitive (CI) import Data.List (find) import Data.Maybe (fromMaybe) #if MIN_VERSION_base(4,5,0) @@ -24,7 +23,6 @@ #endif import Network.HTTP.Types (Status, statusCode) import Network.Wai (Request(..)) -import Network.Wai.Logger.Date import Network.Wai.Logger.IP import System.Log.FastLogger @@ -42,7 +40,7 @@ | FromFallback -- | Apache style log format. -apacheLogStr :: IPAddrSource -> ZonedDate -> Request -> Status -> Maybe Integer -> LogStr +apacheLogStr :: IPAddrSource -> FormattedTime -> Request -> Status -> Maybe Integer -> LogStr apacheLogStr ipsrc tmstr req status msize = toLogStr (getSourceIP ipsrc req) <> " - - [" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wai-logger-2.2.5/Network/Wai/Logger/Date.hs new/wai-logger-2.2.7/Network/Wai/Logger/Date.hs --- old/wai-logger-2.2.5/Network/Wai/Logger/Date.hs 2016-01-13 08:28:24.000000000 +0100 +++ new/wai-logger-2.2.7/Network/Wai/Logger/Date.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,88 +0,0 @@ -{-# LANGUAGE CPP, OverloadedStrings #-} - --- | --- Formatting time is slow. --- This package provides mechanisms to cache formatted date. -module Network.Wai.Logger.Date ( - -- * Types - DateCacheGetter - , DateCacheUpdater - , ZonedDate - -- * Cache configuration - , DateCacheConf(..) - , zonedDateCacheConf - -- * Date cacher - , clockDateCacher - ) where - -import Control.AutoUpdate (mkAutoUpdate, defaultUpdateSettings, updateAction) -import Data.ByteString (ByteString) -#if WINDOWS -import qualified Data.ByteString.Char8 as BS -import Data.Time (UTCTime, formatTime, getCurrentTime, utcToLocalZonedTime) -# if MIN_VERSION_time(1,5,0) -import Data.Time (defaultTimeLocale) -# else -import System.Locale (defaultTimeLocale) -# endif -#else -import Data.UnixTime (formatUnixTime, fromEpochTime) -import System.Posix (EpochTime, epochTime) -#endif - ----------------------------------------------------------------- - --- | Getting cached 'ZonedDate'. -type DateCacheGetter = IO ZonedDate --- | Updateing cached 'ZonedDate'. This should be called every second. --- See the source code of 'withStdoutLogger'. -type DateCacheUpdater = IO () - ----------------------------------------------------------------- - --- | A type for zoned date. -type ZonedDate = ByteString - ----------------------------------------------------------------- - -data DateCacheConf t = DateCacheConf { - -- | A function to get a time. E.g 'epochTime' and 'getCurrentTime'. - getTime :: IO t - -- | A function to format a time. - , formatDate :: t -> IO ByteString - } - -#if WINDOWS --- | Zoned date cacher using UTC. -zonedDateCacheConf :: DateCacheConf UTCTime -zonedDateCacheConf = DateCacheConf { - getTime = getCurrentTime - , formatDate = \ut -> do - zt <- utcToLocalZonedTime ut - return $ BS.pack $ formatTime defaultTimeLocale "%d/%b/%Y:%T %z" zt - } -#else --- | Zoned date cacher using UnixTime. -zonedDateCacheConf :: DateCacheConf EpochTime -zonedDateCacheConf = DateCacheConf { - getTime = epochTime - , formatDate = formatUnixTime "%d/%b/%Y:%T %z" . fromEpochTime - } -#endif - ----------------------------------------------------------------- - --- | --- Returning 'DateCacheGetter' and 'DateCacheUpdater'. --- --- Note: Since version 2.1.2, this function uses the auto-update package --- internally, and therefore the @DateCacheUpdater@ value returned need --- not be called. To wit, the return value is in fact an empty action. - -clockDateCacher :: IO (DateCacheGetter, DateCacheUpdater) -clockDateCacher = do - getter <- mkAutoUpdate defaultUpdateSettings - { updateAction = getTime zonedDateCacheConf - >>= formatDate zonedDateCacheConf - } - return (getter, return ()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wai-logger-2.2.5/Network/Wai/Logger.hs new/wai-logger-2.2.7/Network/Wai/Logger.hs --- old/wai-logger-2.2.5/Network/Wai/Logger.hs 2016-01-13 08:28:24.000000000 +0100 +++ new/wai-logger-2.2.7/Network/Wai/Logger.hs 2016-04-18 07:47:40.000000000 +0200 @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + -- | Apache style logger for WAI applications. -- -- An example: @@ -39,29 +41,26 @@ , IPAddrSource(..) , LogType(..) , FileLogSpec(..) - -- * Date cacher + -- * Utilities + , showSockAddr + , logCheck + -- * Backward compability , clockDateCacher , ZonedDate , DateCacheGetter , DateCacheUpdater - -- * Utilities - , logCheck - , showSockAddr ) where +#if __GLASGOW_HASKELL__ < 709 import Control.Applicative ((<$>)) -import Control.AutoUpdate (mkAutoUpdate, defaultUpdateSettings, updateAction) -import Control.Concurrent (MVar, newMVar, tryTakeMVar, putMVar) -import Control.Exception (handle, SomeException(..), bracket) -import Control.Monad (when, void) +#endif +import Control.Exception (bracket) +import Control.Monad (void) import Network.HTTP.Types (Status) import Network.Wai (Request) -import System.EasyFile (getFileSize) import System.Log.FastLogger import Network.Wai.Logger.Apache -import Network.Wai.Logger.Date -import Network.Wai.Logger.IORef import Network.Wai.Logger.IP (showSockAddr) ---------------------------------------------------------------- @@ -74,8 +73,8 @@ app aplogger where setup = do - (getter, _updater) <- clockDateCacher - apf <- initLogger FromFallback (LogStdout 4096) getter + tgetter <- newTimeCache simpleTimeFormat + apf <- initLogger FromFallback (LogStdout 4096) tgetter let aplogger = apacheLogger apf remover = logRemover apf return (aplogger, remover) @@ -96,135 +95,50 @@ , logRemover :: IO () } --- | Logger Type. -data LogType = LogNone -- ^ No logging. - | LogStdout BufSize -- ^ Logging to stdout. - -- 'BufSize' is a buffer size - -- for each capability. - | LogFile FileLogSpec BufSize -- ^ Logging to a file. - -- 'BufSize' is a buffer size - -- for each capability. - -- File rotation is done on-demand. - | LogCallback (LogStr -> IO ()) (IO ()) - ---------------------------------------------------------------- --- | --- Creating 'ApacheLogger' according to 'LogType'. -initLogger :: IPAddrSource -> LogType -> DateCacheGetter +-- | Creating 'ApacheLogger' according to 'LogType'. +initLogger :: IPAddrSource -> LogType -> IO FormattedTime -> IO ApacheLoggerActions -initLogger _ LogNone _ = noLoggerInit -initLogger ipsrc (LogStdout size) dateget = stdoutLoggerInit ipsrc size dateget -initLogger ipsrc (LogFile spec size) dateget = fileLoggerInit ipsrc spec size dateget -initLogger ipsrc (LogCallback cb flush) dateget = callbackLoggerInit ipsrc cb flush dateget - ----------------------------------------------------------------- +initLogger ipsrc typ tgetter = do + (fl, cleanUp) <- newFastLogger typ + return $ ApacheLoggerActions (apache fl ipsrc tgetter) (return ()) cleanUp -noLoggerInit :: IO ApacheLoggerActions -noLoggerInit = return ApacheLoggerActions { - apacheLogger = noLogger - , logRotator = noRotator - , logRemover = noRemover - } - where - noLogger _ _ _ = return () - noRotator = return () - noRemover = return () - -stdoutLoggerInit :: IPAddrSource -> BufSize -> DateCacheGetter - -> IO ApacheLoggerActions -stdoutLoggerInit ipsrc size dateget = do - lgrset <- newStdoutLoggerSet size - let logger = apache (pushLogStr lgrset) ipsrc dateget - noRotator = return () - remover = rmLoggerSet lgrset - return ApacheLoggerActions { - apacheLogger = logger - , logRotator = noRotator - , logRemover = remover - } - -fileLoggerInit :: IPAddrSource -> FileLogSpec -> BufSize -> DateCacheGetter - -> IO ApacheLoggerActions -fileLoggerInit ipsrc spec size dateget = do - lgrset <- newFileLoggerSet size $ log_file spec - ref <- newIORef (0 :: Int) - mvar <- newMVar () - let logger a b c = do - cnt <- decrease ref - apache (pushLogStr lgrset) ipsrc dateget a b c - when (cnt <= 0) $ tryRotate lgrset spec ref mvar - noRotator = return () - remover = rmLoggerSet lgrset - return ApacheLoggerActions { - apacheLogger = logger - , logRotator = noRotator - , logRemover = remover - } - -decrease :: IORef Int -> IO Int -decrease ref = atomicModifyIORef' ref (\x -> (x - 1, x - 1)) - -callbackLoggerInit :: IPAddrSource -> (LogStr -> IO ()) -> IO () -> DateCacheGetter - -> IO ApacheLoggerActions -callbackLoggerInit ipsrc cb flush dateget = do - flush' <- mkAutoUpdate defaultUpdateSettings - { updateAction = flush - } - let logger a b c = apache cb ipsrc dateget a b c >> flush' - noRotator = return () - remover = return () - return ApacheLoggerActions { - apacheLogger = logger - , logRotator = noRotator - , logRemover = remover - } +--- | Checking if a log file can be written if 'LogType' is 'LogFileNoRotate' or 'LogFile'. +logCheck :: LogType -> IO () +logCheck LogNone = return () +logCheck (LogStdout _) = return () +logCheck (LogStderr _) = return () +logCheck (LogFileNoRotate fp _) = check fp +logCheck (LogFile spec _) = check (log_file spec) +logCheck (LogCallback _ _) = return () ---------------------------------------------------------------- -apache :: (LogStr -> IO ()) -> IPAddrSource -> DateCacheGetter -> ApacheLogger +apache :: (LogStr -> IO ()) -> IPAddrSource -> IO FormattedTime -> ApacheLogger apache cb ipsrc dateget req st mlen = do zdata <- dateget cb (apacheLogStr ipsrc zdata req st mlen) ----------------------------------------------------------------- +--------------------------------------------------------------- -tryRotate :: LoggerSet -> FileLogSpec -> IORef Int -> MVar () -> IO () -tryRotate lgrset spec ref mvar = bracket lock unlock rotateFiles - where - lock = tryTakeMVar mvar - unlock Nothing = return () - unlock _ = putMVar mvar () - rotateFiles Nothing = return () - rotateFiles _ = do - msiz <- getSize - case msiz of - -- A file is not available. - -- So, let's set a big value to the counter so that - -- this function is not called frequently. - Nothing -> writeIORef ref 1000000 - Just siz - | siz > limit -> do - rotate spec - renewLoggerSet lgrset - writeIORef ref $ estimate limit - | otherwise -> do - writeIORef ref $ estimate (limit - siz) - file = log_file spec - limit = log_file_size spec - getSize = handle (\(SomeException _) -> return Nothing) $ do - -- The log file is locked by GHC. - -- We need to get its file size by the way not using locks. - Just . fromIntegral <$> getFileSize file - -- 200 is an ad-hoc value for the length of log line. - estimate x = fromInteger (x `div` 200) +-- | Getting cached 'ZonedDate'. +type DateCacheGetter = IO ZonedDate ----------------------------------------------------------------- +-- | Updateing cached 'ZonedDate'. This should be called every second. +-- See the source code of 'withStdoutLogger'. +type DateCacheUpdater = IO () + +-- | A type for zoned date. +type ZonedDate = FormattedTime -- | --- Checking if a log file can be written if 'LogType' is 'LogFile'. -logCheck :: LogType -> IO () -logCheck LogNone = return () -logCheck (LogStdout _) = return () -logCheck (LogFile spec _) = check spec -logCheck (LogCallback _ _) = return () +-- Returning 'DateCacheGetter' and 'DateCacheUpdater'. +-- +-- Note: Since version 2.1.2, this function uses the auto-update package +-- internally, and therefore the @DateCacheUpdater@ value returned need +-- not be called. To wit, the return value is in fact an empty action. +clockDateCacher :: IO (DateCacheGetter, DateCacheUpdater) +clockDateCacher = do + tgetter <- newTimeCache simpleTimeFormat + return (tgetter, return ()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wai-logger-2.2.5/wai-logger.cabal new/wai-logger-2.2.7/wai-logger.cabal --- old/wai-logger-2.2.5/wai-logger.cabal 2016-01-13 08:28:24.000000000 +0100 +++ new/wai-logger-2.2.7/wai-logger.cabal 2016-04-18 07:47:40.000000000 +0200 @@ -1,5 +1,5 @@ Name: wai-logger -Version: 2.2.5 +Version: 2.2.7 Author: Kazu Yamamoto <kazu@iij.ad.jp> Maintainer: Kazu Yamamoto <kazu@iij.ad.jp> License: BSD3 @@ -15,17 +15,14 @@ GHC-Options: -Wall Exposed-Modules: Network.Wai.Logger Other-Modules: Network.Wai.Logger.Apache - Network.Wai.Logger.Date Network.Wai.Logger.IP Network.Wai.Logger.IORef Build-Depends: base >= 4 && < 5 - , auto-update , blaze-builder , byteorder , bytestring , case-insensitive - , easy-file >= 0.2 - , fast-logger >= 2.2 + , fast-logger >= 2.4.5 , http-types , network , wai >= 2.0.0
participants (1)
-
root@hilbert.suse.de