on master help sign in
wai-extra: Add NOINLINE pragmas as needed

The docs for `unsafePerformIO` say: Use {-# NOINLINE foo #-} as a pragma on any function foo that calls unsafePerformIO. If the call is inlined, the I/O may be performed more than once.

commitea651898d2f72fc0d1bd997cd5cce1a87938be42 authorErik de Castro Lopo <erikd@mega-nerd.com> dateFri 3 Jul 2015, 15:07 (11 years ago) parentbffaa1a
1 file changed+2
wai-extra/Network/Wai/Middleware/RequestLogger.hs+2
wai-extra/Network/Wai/Middleware/RequestLogger.hs+2
@@ -119,6 +119,7 @@ customMiddleware cb getdate formatter app req sendResponse = app req $ \res -> d
119119
120120-- | Production request logger middleware.
121121-- Implemented on top of "logCallback", but prints to 'stdout'
122+{-# NOINLINE logStdout #-}
122123logStdout :: Middleware
123124logStdout = unsafePerformIO $ mkRequestLogger def { outputFormat = Apache FromSocket }
124125
@@ -127,6 +128,7 @@ logStdout = unsafePerformIO $ mkRequestLogger def { outputFormat = Apache FromSo
127128--
128129-- Flushes 'stdout' on each request, which would be inefficient in production use.
129130-- Use "logStdout" in production.
131+{-# NOINLINE logStdoutDev #-}
130132logStdoutDev :: Middleware
131133logStdoutDev = unsafePerformIO $ mkRequestLogger def
132134