From 8e2f85f6b4662676f0d7addaff9bf2c7d751bb63 Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Thu, 7 Jan 2021 14:25:15 +0100 Subject: Refactor Logger Before this patch, the only way to override GHC's default logging behavior was to set `log_action`, `dump_action` and `trace_action` fields in DynFlags. This patch introduces a new Logger abstraction and stores it in HscEnv instead. This is part of #17957 (avoid storing state in DynFlags). DynFlags are duplicated and updated per-module (because of OPTIONS_GHC pragma), so we shouldn't store global state in them. This patch also fixes a race in parallel "--make" mode which updated the `generatedDumps` IORef concurrently. Bump haddock submodule The increase in MultilayerModules is tracked in #19293. Metric Increase: MultiLayerModules --- ghc/GHCi/UI/Monad.hs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ghc/GHCi/UI') diff --git a/ghc/GHCi/UI/Monad.hs b/ghc/GHCi/UI/Monad.hs index b371a9b8b4..ed06d81d75 100644 --- a/ghc/GHCi/UI/Monad.hs +++ b/ghc/GHCi/UI/Monad.hs @@ -57,6 +57,7 @@ import GHCi.RemoteTypes import GHC.Hs (ImportDecl, GhcPs, GhciLStmt, LHsDecl) import GHC.Hs.Utils import GHC.Utils.Misc +import GHC.Utils.Logger import GHC.Utils.Exception hiding (uninterruptibleMask, mask, catch) import Numeric @@ -307,13 +308,20 @@ instance MonadIO GHCi where instance HasDynFlags GHCi where getDynFlags = getSessionDynFlags +instance HasLogger GHCi where + getLogger = hsc_logger <$> getSession + instance GhcMonad GHCi where setSession s' = liftGhc $ setSession s' getSession = liftGhc $ getSession + instance HasDynFlags (InputT GHCi) where getDynFlags = lift getDynFlags +instance HasLogger (InputT GHCi) where + getLogger = lift getLogger + instance GhcMonad (InputT GHCi) where setSession = lift . setSession getSession = lift getSession -- cgit v1.2.1