This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "snap-core".

The branch, master has been updated
       via  0a5b831d78c2d727a107e6659b20cd86d9b34364 (commit)
      from  dc4fec02812b88810791de9f023e2a8ace19c559 (commit)


Summary of changes:
 snap-core.cabal            |   20 ++++++++++++++++++++
 src/Snap/Internal/Debug.hs |   14 ++++++++++----
 2 files changed, 30 insertions(+), 4 deletions(-)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0a5b831d78c2d727a107e6659b20cd86d9b34364
Author: Gregory Collins <[email protected]>
Date:   Tue Sep 21 13:13:04 2010 -0400

    Add configure-time flag to disable debug logging altogether

diff --git a/snap-core.cabal b/snap-core.cabal
index 4a08864..d45697d 100644
--- a/snap-core.cabal
+++ b/snap-core.cabal
@@ -103,9 +103,25 @@ Flag portable
                optimizations such as C routines will be used.
   Default: False
 
+
+Flag no-debug
+  Description: Disable any debug logging code. Without this flag, Snap will
+               test the DEBUG environment variable to decide whether to do
+               logging, and this introduces a tiny amount of overhead
+               (a call into a function pointer) because the calls to 'debug'
+               cannot be inlined. Users who want to squeeze out maximum
+               performance can set the no-debug flag to get a version of Snap
+               which has debug calls that should be inlined away.
+               
+  Default: False
+
+
 Library
   hs-source-dirs: src
 
+  if flag(no-debug)
+    cpp-options: -DNODEBUG
+
   if flag(portable) || os(windows)
     cpp-options: -DPORTABLE
   else
@@ -158,12 +174,16 @@ Library
   else
     ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2
 
+
 Executable snap
   hs-source-dirs: src
   main-is: Snap/Starter.hs
 
   other-modules: Snap.StarterTH
 
+  if flag(no-debug)
+    cpp-options: -DNODEBUG
+
   build-depends:
     attoparsec >= 0.8.1 && < 0.9,
     base >= 4 && < 5,
diff --git a/src/Snap/Internal/Debug.hs b/src/Snap/Internal/Debug.hs
index 4bd0493..8ecf2fc 100644
--- a/src/Snap/Internal/Debug.hs
+++ b/src/Snap/Internal/Debug.hs
@@ -7,8 +7,9 @@
 -- depends on it.
 
 {-# LANGUAGE BangPatterns        #-}
+{-# LANGUAGE CPP                 #-}
 {-# LANGUAGE ScopedTypeVariables #-}
-{-# OPTIONS_GHC -fno-cse #-}
+{-# OPTIONS_GHC -fno-cse         #-}
 
 
 module Snap.Internal.Debug where
@@ -28,11 +29,12 @@ import           System.IO.Unsafe
 import           Text.Printf
 ------------------------------------------------------------------------------
 
+debug, debugErrno :: forall m . (MonadIO m => String -> m ())
 
 
+#ifndef NODEBUG
 
 {-# NOINLINE debug #-}
-debug :: forall m . (MonadIO m => String -> m ())
 debug = let !x = unsafePerformIO $! do
             !e <- try $ getEnv "DEBUG"
             
@@ -48,7 +50,6 @@ debug = let !x = unsafePerformIO $! do
 
 
 {-# NOINLINE debugErrno #-}
-debugErrno :: forall m . (MonadIO m => String -> m ())
 debugErrno = let !x = unsafePerformIO $ do
                  e <- try $ getEnv "DEBUG"
                  
@@ -101,11 +102,16 @@ debugErrnoOn loc = liftIO $ do
     debug $ show ex
 ------------------------------------------------------------------------------
 
+#else
+
+debug      = debugIgnore
+debugErrno = debugErrnoIgnore
+
+#endif
 
 ------------------------------------------------------------------------------
 debugIgnore :: (MonadIO m) => String -> m ()
 debugIgnore _ = return ()
-{-# NOINLINE debugIgnore #-}
 
 debugErrnoIgnore :: (MonadIO m) => String -> m ()
 debugErrnoIgnore _ = return ()
-----------------------------------------------------------------------


hooks/post-receive
-- 
snap-core
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap

Reply via email to