Add --debug option. Closes: #627499

This takes advantage of the debug logging done by missingh, and I added
my own debug messages for executeFile calls. There are still some other
low-level ways git-annex runs stuff that are not shown by debugging,
but this gets most of it easily.
This commit is contained in:
Joey Hess 2011-05-21 11:52:13 -04:00
parent 1876db50f2
commit 93a4f3d4e6
6 changed files with 23 additions and 4 deletions

View file

@ -8,6 +8,8 @@
module Options where
import System.Console.GetOpt
import System.Log.Logger
import Control.Monad.State (liftIO)
import qualified Annex
import Types
@ -27,7 +29,9 @@ commonOptions =
, Option ['q'] ["quiet"] (NoArg (setquiet True))
"avoid verbose output"
, Option ['v'] ["verbose"] (NoArg (setquiet False))
"allow verbose output"
"allow verbose output (default)"
, Option ['d'] ["debug"] (NoArg (setdebug))
"show debug messages"
, Option ['b'] ["backend"] (ReqArg setforcebackend paramName)
"specify key-value backend to use"
]
@ -36,3 +40,4 @@ commonOptions =
setfast v = Annex.changeState $ \s -> s { Annex.fast = v }
setquiet v = Annex.changeState $ \s -> s { Annex.quiet = v }
setforcebackend v = Annex.changeState $ \s -> s { Annex.forcebackend = Just v }
setdebug = liftIO $ updateGlobalLogger "" $ setLevel DEBUG

View file

@ -12,7 +12,7 @@ import Control.Exception.Extensible (IOException)
import qualified Data.Map as M
import Control.Monad.State (liftIO)
import System.FilePath
import System.Posix.Process
import System.Posix.Process hiding (executeFile)
import System.Posix.IO
import System.IO
import System.IO.Error (try)

View file

@ -7,7 +7,6 @@
module RsyncFile where
import System.Posix.Process
import Data.String.Utils
import Utility

View file

@ -17,6 +17,7 @@ module Utility (
relPathDirToFile,
boolSystem,
boolSystemEnv,
executeFile,
shellEscape,
shellUnEscape,
unsetFileMode,
@ -39,7 +40,8 @@ module Utility (
import System.IO
import System.Exit
import System.Posix.Process
import qualified System.Posix.Process
import System.Posix.Process hiding (executeFile)
import System.Posix.Signals
import System.Posix.Files
import System.Posix.Types
@ -52,6 +54,7 @@ import Foreign (complement)
import Data.List
import Data.Maybe
import Control.Monad (liftM2, when, unless)
import System.Log.Logger
{- A type for parameters passed to a shell command. A command can
- be passed either some Params (multiple parameters can be included,
@ -104,6 +107,13 @@ boolSystemEnv command params env = do
restoresignals oldint oldset
executeFile command True (toCommand params) env
{- executeFile with debug logging -}
executeFile :: FilePath -> Bool -> [String] -> Maybe [(String, String)] -> IO a
executeFile c path p e = do
debugM "Utility.executeFile" $
"Running: " ++ c ++ " " ++ show p ++ " " ++ maybe "" show e
System.Posix.Process.executeFile c path p e
{- Escapes a filename or other parameter to be safely able to be exposed to
- the shell. -}
shellEscape :: String -> String

1
debian/changelog vendored
View file

@ -2,6 +2,7 @@ git-annex (0.20110517) UNRELEASED; urgency=low
* status: New subcommand to show info about an annex, including its size.
* --backend now overrides any backend configured in .gitattributes files.
* Add --debug option. Closes: #627499
-- Joey Hess <joeyh@debian.org> Mon, 16 May 2011 20:27:46 -0400

View file

@ -330,6 +330,10 @@ Many git-annex commands will stage changes for later `git commit` by you.
Enable verbose logging.
* --debug
Show debug messages.
* --from=repository
Specifies a repository that content will be retrieved from, or that