diff options
| author | Joey Hess <id@joeyh.name> | 2014-11-26 10:51:41 -0400 |
|---|---|---|
| committer | Joey Hess <id@joeyh.name> | 2014-11-26 10:51:41 -0400 |
| commit | 3d42f1fa19577a7f9c2b629281fb5675772a0455 (patch) | |
| tree | a5d0cee89993c3616505aedff758b14329b4a4ad | |
| parent | 1d8e08f2ac5a1d996e7aab1df0c6c7ff5631210f (diff) | |
| parent | 5a104675e4e18812f8794d9631d54c91b6d9be12 (diff) | |
Merge branch 'joeyconfig'
| -rw-r--r-- | debian/changelog | 2 | ||||
| -rw-r--r-- | doc/debugging.mdwn | 5 | ||||
| -rw-r--r-- | doc/usage.mdwn | 12 | ||||
| -rw-r--r-- | src/Propellor/Message.hs | 27 |
4 files changed, 36 insertions, 10 deletions
diff --git a/debian/changelog b/debian/changelog index 8d0c9316..17801470 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,6 +19,8 @@ propellor (1.1.0) UNRELEASED; urgency=medium commit. * cron.runPropellor now runs propellor, rather than using its Makefile. This is more robust. + * propellor.debug can be set in the git config to enable more persistent + debugging output. -- Joey Hess <joeyh@debian.org> Sat, 22 Nov 2014 00:12:35 -0400 diff --git a/doc/debugging.mdwn b/doc/debugging.mdwn index f656ac43..acceca86 100644 --- a/doc/debugging.mdwn +++ b/doc/debugging.mdwn @@ -1,5 +1,6 @@ -Set `PROPELLOR_DEBUG=1` to make propellor print out all the commands it runs -and any other debug messages that Properties choose to emit. +Set `PROPELLOR_DEBUG=1` in the environment, or `git config propellor.debug 1` +to make propellor print out all the commands it runs and any other debug +messages that Properties choose to emit. Another handy debugging tip is to load up your config.hs in ghci, and look at `hosts`. This will show the Properties of a Host, as well as the Info diff --git a/doc/usage.mdwn b/doc/usage.mdwn index 093ec34e..6ef2e965 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -101,6 +101,18 @@ and configured in haskell. Set `PROPELLOR_DEBUG=1` to make propellor output each command it runs and other debugging information. +# GIT CONFIGURATION + +`git config propellor.debug 1` will configure propellor to output debugging +information. + +The usual git configuration controls which centralized repository (if any) +propellor pushes and pulls from. + +Additionally, the url of a remote named "deploy", if it exists +in your ~/.propellor/ repository, is used as the origin url for +the other repositories. + # SH AUTHOR Joey Hess <id@joeyh.name> diff --git a/src/Propellor/Message.hs b/src/Propellor/Message.hs index 09a92538..bcd99649 100644 --- a/src/Propellor/Message.hs +++ b/src/Propellor/Message.hs @@ -11,10 +11,14 @@ import System.Log.Handler.Simple import "mtl" Control.Monad.Reader import Data.Maybe import Control.Applicative +import System.Directory +import Control.Monad.IfElse import Propellor.Types import Utility.Monad import Utility.Env +import Utility.Process +import Utility.Exception data MessageHandle = ConsoleMessageHandle @@ -99,17 +103,24 @@ colorLine h intensity color msg = do putStrLn "" hFlush stdout --- | Causes a debug message to be displayed when PROPELLOR_DEBUG=1 debug :: [String] -> IO () debug = debugM "propellor" . unwords checkDebugMode :: IO () checkDebugMode = go =<< getEnv "PROPELLOR_DEBUG" where - go (Just "1") = do - f <- setFormatter - <$> streamHandler stderr DEBUG - <*> pure (simpleLogFormatter "[$time] $msg") - updateGlobalLogger rootLoggerName $ - setLevel DEBUG . setHandlers [f] - go _ = noop + go (Just "1") = enableDebugMode + go (Just _) = noop + go Nothing = whenM (doesDirectoryExist ".git") $ + whenM (any (== "1") . lines <$> getgitconfig) $ + enableDebugMode + getgitconfig = catchDefaultIO "" $ + readProcess "git" ["config", "propellor.debug"] + +enableDebugMode :: IO () +enableDebugMode = do + f <- setFormatter + <$> streamHandler stderr DEBUG + <*> pure (simpleLogFormatter "[$time] $msg") + updateGlobalLogger rootLoggerName $ + setLevel DEBUG . setHandlers [f] |
