switch from hslogger to purpose-built Utility.Debug
This uses a DebugSelector, rather than debug levels, which will allow for a later option like --debug-from=Process to only see debuging about running processes. The module name that contains the thing being debugged is used as the DebugSelector (in most cases; does not need to be a hard and fast rule). Debug calls were changed to add that. hslogger did not display that first parameter to debugM, but the DebugSelector does get displayed. Also fastDebug will allow doing debugging in places that are used in tight loops, with the DebugSelector coming from the Annex Reader essentially for free. Not done yet.
This commit is contained in:
parent
19c672e710
commit
aaba83795b
26 changed files with 194 additions and 105 deletions
|
@ -22,11 +22,9 @@ module Assistant.Monad (
|
|||
asIO2,
|
||||
ThreadName,
|
||||
debug,
|
||||
notice
|
||||
) where
|
||||
|
||||
import "mtl" Control.Monad.Reader
|
||||
import System.Log.Logger
|
||||
import qualified Control.Monad.Fail as Fail
|
||||
|
||||
import Annex.Common
|
||||
|
@ -43,6 +41,7 @@ import Assistant.Types.RepoProblem
|
|||
import Assistant.Types.ThreadName
|
||||
import Assistant.Types.RemoteControl
|
||||
import Assistant.Types.CredPairCache
|
||||
import qualified Utility.Debug as Debug
|
||||
|
||||
newtype Assistant a = Assistant { mkAssistant :: ReaderT AssistantData IO a }
|
||||
deriving (
|
||||
|
@ -139,12 +138,6 @@ asIO2 a = do
|
|||
io <<~ v = reader v >>= liftIO . io
|
||||
|
||||
debug :: [String] -> Assistant ()
|
||||
debug = logaction debugM
|
||||
|
||||
notice :: [String] -> Assistant ()
|
||||
notice = logaction noticeM
|
||||
|
||||
logaction :: (String -> String -> IO ()) -> [String] -> Assistant ()
|
||||
logaction a ws = do
|
||||
debug ws = do
|
||||
ThreadName name <- getAssistant threadName
|
||||
liftIO $ a name $ unwords $ (name ++ ":") : ws
|
||||
liftIO $ Debug.debug (Debug.DebugSource (encodeBS name)) (unwords ws)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue