handling logging level
This commit is contained in:
@@ -78,6 +78,17 @@ gmLog level loc' doc = do
|
||||
|
||||
gmlJournal (GhcModLog Nothing (Last Nothing) [(level, loc', msgDoc)])
|
||||
|
||||
-- | Appends a collection of logs to the logging environment, with effects
|
||||
-- | if their log level specifies it should
|
||||
gmLog' :: (MonadIO m, GmLog m, GmOut m) => GhcModLog -> m ()
|
||||
gmLog' newLog@ GhcModLog { gmLogMessages } = do
|
||||
GhcModLog { gmLogLevel = Just level' } <- gmlHistory
|
||||
mapM_ (\(level, _, msgDoc) -> when (level <= level') $ gmErrStrLn (docToString msgDoc)) gmLogMessages
|
||||
-- instance Monoid GhcModLog takes the second debug level for some reason, so we need to force this to nothing
|
||||
gmlJournal (GhcModLog Nothing (Last Nothing) gmLogMessages)
|
||||
where
|
||||
docToString msgDoc = dropWhileEnd isSpace $ gmRenderDoc msgDoc
|
||||
|
||||
gmVomit :: (MonadIO m, GmLog m, GmOut m, GmEnv m) => String -> Doc -> String -> m ()
|
||||
gmVomit filename doc content = do
|
||||
gmLog GmVomit "" $ doc <+>: text content
|
||||
|
||||
Reference in New Issue
Block a user