Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package ghc-wai-extra for openSUSE:Factory 
checked in at 2022-02-11 23:09:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-wai-extra (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-wai-extra.new.1956 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-wai-extra"

Fri Feb 11 23:09:58 2022 rev:10 rq:953560 version:3.1.8

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-wai-extra/ghc-wai-extra.changes      
2021-11-11 21:37:36.644940671 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-wai-extra.new.1956/ghc-wai-extra.changes    
2022-02-11 23:11:59.835395040 +0100
@@ -1,0 +2,8 @@
+Mon Jan  3 14:20:11 UTC 2022 - Peter Simons <[email protected]>
+
+- Update wai-extra to version 3.1.8.
+  ## 3.1.8
+
+  * Added an `ApacheWithSettings` output format for `RequestLogger` that 
allows request filtering similar to `DetailedWithSettings` and logging of the 
current user via wai-logger's `initLoggerUser` 
[#866](https://github.com/yesodweb/wai/pull/866)
+
+-------------------------------------------------------------------

Old:
----
  wai-extra-3.1.7.tar.gz

New:
----
  wai-extra-3.1.8.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-wai-extra.spec ++++++
--- /var/tmp/diff_new_pack.Bva61R/_old  2022-02-11 23:12:00.243396219 +0100
+++ /var/tmp/diff_new_pack.Bva61R/_new  2022-02-11 23:12:00.247396232 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package ghc-wai-extra
 #
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
 %global pkg_name wai-extra
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        3.1.7
+Version:        3.1.8
 Release:        0
 Summary:        Provides some basic WAI handlers and middleware
 License:        MIT

++++++ wai-extra-3.1.7.tar.gz -> wai-extra-3.1.8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-extra-3.1.7/ChangeLog.md 
new/wai-extra-3.1.8/ChangeLog.md
--- old/wai-extra-3.1.7/ChangeLog.md    2021-10-20 09:16:34.000000000 +0200
+++ new/wai-extra-3.1.8/ChangeLog.md    2022-01-03 11:41:01.000000000 +0100
@@ -1,5 +1,9 @@
 # Changelog for wai-extra
 
+## 3.1.8
+
+* Added an `ApacheWithSettings` output format for `RequestLogger` that allows 
request filtering similar to `DetailedWithSettings` and logging of the current 
user via wai-logger's `initLoggerUser` 
[#866](https://github.com/yesodweb/wai/pull/866)
+
 ## 3.1.7
 
 * Added new `mPrelogRequests` option to `DetailedSettings` 
[#857](https://github.com/yesodweb/wai/pull/857)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/wai-extra-3.1.7/Network/Wai/Middleware/RequestLogger.hs 
new/wai-extra-3.1.8/Network/Wai/Middleware/RequestLogger.hs
--- old/wai-extra-3.1.7/Network/Wai/Middleware/RequestLogger.hs 2021-10-20 
09:16:34.000000000 +0200
+++ new/wai-extra-3.1.8/Network/Wai/Middleware/RequestLogger.hs 2022-01-03 
14:58:59.000000000 +0100
@@ -9,11 +9,17 @@
       -- * Create more versions
     , mkRequestLogger
     , RequestLoggerSettings
+    , defaultRequestLoggerSettings
     , outputFormat
     , autoFlush
     , destination
     , OutputFormat (..)
-    , DetailedSettings(..)
+    , ApacheSettings
+    , defaultApacheSettings
+    , setApacheIPAddrSource
+    , setApacheRequestFilter
+    , setApacheUserGetter
+    , DetailedSettings (..)
     , OutputFormatter
     , OutputFormatterWithDetails
     , OutputFormatterWithDetailsAndHeaders
@@ -51,16 +57,65 @@
 import Network.Wai.Middleware.RequestLogger.Internal
 import Network.Wai.Header (contentLength)
 import Data.Text.Encoding (decodeUtf8')
+import Network.Wai (Request)
 
 -- | The logging format.
 data OutputFormat
   = Apache IPAddrSource
+  | ApacheWithSettings ApacheSettings -- ^ @since 3.1.8
   | Detailed Bool -- ^ use colors?
   | DetailedWithSettings DetailedSettings -- ^ @since 3.1.3
   | CustomOutputFormat OutputFormatter
   | CustomOutputFormatWithDetails OutputFormatterWithDetails
   | CustomOutputFormatWithDetailsAndHeaders 
OutputFormatterWithDetailsAndHeaders
 
+-- | Settings for the `ApacheWithSettings` `OutputFormat`. This is purposely 
kept as an abstract data
+-- type so that new settings can be added without breaking backwards
+-- compatibility. In order to create an 'ApacheSettings' value, use 
'defaultApacheSettings'
+-- and the various \'setApache\' functions to modify individual fields. For 
example:
+--
+-- > setApacheIPAddrSource FromHeader defaultApacheSettings
+--
+-- @since 3.1.8
+data ApacheSettings = ApacheSettings
+    { apacheIPAddrSource :: IPAddrSource
+    , apacheUserGetter :: Request -> Maybe BS.ByteString
+    , apacheRequestFilter :: Request -> Response -> Bool
+    }
+
+defaultApacheSettings :: ApacheSettings
+defaultApacheSettings = ApacheSettings
+    { apacheIPAddrSource = FromSocket
+    , apacheRequestFilter = \_ _ -> True
+    , apacheUserGetter = \_ -> Nothing
+    }
+
+-- | Where to take IP addresses for clients from. See 'IPAddrSource' for more 
information.
+--
+-- Default value: FromSocket
+--
+-- @since 3.1.8
+setApacheIPAddrSource :: IPAddrSource -> ApacheSettings -> ApacheSettings
+setApacheIPAddrSource x y = y { apacheIPAddrSource = x }
+
+-- | Function that allows you to filter which requests are logged, based on
+-- the request and response
+--
+-- Default: log all requests
+--
+-- @since 3.1.8
+setApacheRequestFilter :: (Request -> Response -> Bool) -> ApacheSettings -> 
ApacheSettings
+setApacheRequestFilter x y = y { apacheRequestFilter = x }
+
+-- | Function that allows you to get the current user from the request, which
+-- will then be added in the log.
+--
+-- Default: return no user
+--
+-- @since 3.1.8
+setApacheUserGetter :: (Request -> Maybe BS.ByteString) -> ApacheSettings -> 
ApacheSettings
+setApacheUserGetter x y = y { apacheUserGetter = x }
+
 -- | Settings for the `Detailed` `OutputFormat`.
 --
 -- `mModifyParams` allows you to pass a function to hide confidential
@@ -141,12 +196,15 @@
     , destination :: Destination
     }
 
+defaultRequestLoggerSettings :: RequestLoggerSettings
+defaultRequestLoggerSettings = RequestLoggerSettings
+    { outputFormat = Detailed True
+    , autoFlush = True
+    , destination = Handle stdout
+    }
+
 instance Default RequestLoggerSettings where
-    def = RequestLoggerSettings
-        { outputFormat = Detailed True
-        , autoFlush = True
-        , destination = Handle stdout
-        }
+    def = defaultRequestLoggerSettings
 
 mkRequestLogger :: RequestLoggerSettings -> IO Middleware
 mkRequestLogger RequestLoggerSettings{..} = do
@@ -160,7 +218,11 @@
         Apache ipsrc -> do
             getdate <- getDateGetter flusher
             apache <- initLogger ipsrc (LogCallback callback flusher) getdate
-            return $ apacheMiddleware apache
+            return $ apacheMiddleware (\_ _ -> True) apache
+        ApacheWithSettings ApacheSettings{..} -> do
+            getdate <- getDateGetter flusher
+            apache <- initLoggerUser (Just apacheUserGetter) 
apacheIPAddrSource (LogCallback callback flusher) getdate
+            return $ apacheMiddleware apacheRequestFilter apache
         Detailed useColors ->
             let settings = def { useColors = useColors}
             in detailedMiddleware callbackAndFlush settings
@@ -176,10 +238,10 @@
             getdate <- getDateGetter flusher
             return $ customMiddlewareWithDetailsAndHeaders callbackAndFlush 
getdate formatter
 
-apacheMiddleware :: ApacheLoggerActions -> Middleware
-apacheMiddleware ala app req sendResponse = app req $ \res -> do
-    let msize = contentLength (responseHeaders res)
-    apacheLogger ala req (responseStatus res) msize
+apacheMiddleware :: (Request -> Response -> Bool) -> ApacheLoggerActions -> 
Middleware
+apacheMiddleware applyRequestFilter ala app req sendResponse = app req $ \res 
-> do
+    when (applyRequestFilter req res) $
+        apacheLogger ala req (responseStatus res) $ contentLength 
(responseHeaders res)
     sendResponse res
 
 customMiddleware :: Callback -> IO ZonedDate -> OutputFormatter -> Middleware
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-extra-3.1.7/wai-extra.cabal 
new/wai-extra-3.1.8/wai-extra.cabal
--- old/wai-extra-3.1.7/wai-extra.cabal 2021-10-20 09:16:34.000000000 +0200
+++ new/wai-extra-3.1.8/wai-extra.cabal 2022-01-03 11:41:01.000000000 +0100
@@ -1,5 +1,5 @@
 Name:                wai-extra
-Version:             3.1.7
+Version:             3.1.8
 Synopsis:            Provides some basic WAI handlers and middleware.
 description:
   Provides basic WAI handler and middleware functionality:
@@ -99,7 +99,7 @@
                    , case-insensitive          >= 0.2
                    , data-default-class
                    , fast-logger               >= 2.4.5
-                   , wai-logger                >= 2.3.2
+                   , wai-logger                >= 2.3.7
                    , ansi-terminal
                    , resourcet                 >= 0.4.6    && < 1.3
                    , containers

Reply via email to