2021-04-06 19:14:00 +00:00
|
|
|
{- git-annex debugging
|
|
|
|
-
|
2023-07-31 17:06:40 +00:00
|
|
|
- Copyright 2021-2023 Joey Hess <id@joeyh.name>
|
2021-04-06 19:14:00 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Annex.Debug (
|
|
|
|
DebugSelector(..),
|
|
|
|
DebugSource(..),
|
|
|
|
debug,
|
|
|
|
fastDebug,
|
2023-07-31 17:06:40 +00:00
|
|
|
fastDebug',
|
2021-04-06 19:14:00 +00:00
|
|
|
configureDebug,
|
|
|
|
debugSelectorFromGitConfig,
|
|
|
|
parseDebugSelector,
|
|
|
|
) where
|
|
|
|
|
|
|
|
import Common
|
|
|
|
import qualified Annex
|
2023-07-25 19:53:50 +00:00
|
|
|
import Utility.Debug hiding (fastDebug)
|
2021-04-06 19:14:00 +00:00
|
|
|
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 ()
|
2023-07-25 19:53:50 +00:00
|
|
|
fastDebug src msg = do
|
2021-04-06 20:28:37 +00:00
|
|
|
rd <- Annex.getRead id
|
2023-07-31 17:06:40 +00:00
|
|
|
fastDebug' rd src msg
|
|
|
|
|
|
|
|
fastDebug' :: Annex.AnnexRead -> DebugSource -> String -> Annex.Annex ()
|
|
|
|
fastDebug' rd src msg = when (Annex.debugenabled rd) $
|
|
|
|
liftIO $ Utility.Debug.fastDebug (Annex.debugselector rd) src msg
|