2e9d4ac754
Had to add to AnnexRead an indication of whether debugging is enabled. Could have just made setupConsole not install a debug output action that outputs, and have enableDebug be what installs that, but then in the common case where there is no debug selector, and so all debug output is selected, it would run the debug output action every time, which entails an IORef access. Which would make fastDebug too slow..
31 lines
791 B
Haskell
31 lines
791 B
Haskell
{- git-annex debugging
|
|
-
|
|
- Copyright 2021 Joey Hess <id@joeyh.name>
|
|
-
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
-}
|
|
|
|
module Annex.Debug (
|
|
DebugSelector(..),
|
|
DebugSource(..),
|
|
debug,
|
|
fastDebug,
|
|
configureDebug,
|
|
debugSelectorFromGitConfig,
|
|
parseDebugSelector,
|
|
) where
|
|
|
|
import Common
|
|
import qualified Annex
|
|
import Utility.Debug hiding (fastDebug)
|
|
import qualified Utility.Debug
|
|
import Annex.Debug.Utility
|
|
|
|
-- | This is faster than using debug, because the DebugSelector
|
|
-- is read from the Annex monad, which avoids any IORef access overhead
|
|
-- when debugging is not enabled.
|
|
fastDebug :: DebugSource -> String -> Annex.Annex ()
|
|
fastDebug src msg = do
|
|
rd <- Annex.getRead id
|
|
when (Annex.debugenabled rd) $
|
|
liftIO $ Utility.Debug.fastDebug (Annex.debugselector rd) src msg
|