{-# LANGUAGE CPP #-}
module Development.IDE.GHC.Compat.Logger (
putLogHook,
Development.IDE.GHC.Compat.Logger.pushLogHook,
LogActionCompat,
logActionCompat,
defaultLogActionHPutStrDoc,
) where
import Development.IDE.GHC.Compat.Core
import Development.IDE.GHC.Compat.Env as Env
import Development.IDE.GHC.Compat.Outputable
#if MIN_VERSION_ghc(9,0,0)
import GHC.Driver.Session as DynFlags
import GHC.Utils.Outputable
#if MIN_VERSION_ghc(9,2,0)
import GHC.Driver.Env (hsc_logger)
import GHC.Utils.Logger as Logger
#endif
#else
import DynFlags
import Outputable (queryQual)
#endif
putLogHook :: Logger -> HscEnv -> HscEnv
putLogHook :: Logger -> HscEnv -> HscEnv
putLogHook Logger
logger HscEnv
env =
#if MIN_VERSION_ghc(9,2,0)
env { hsc_logger = logger }
#else
DynFlags -> HscEnv -> HscEnv
hscSetFlags ((HscEnv -> DynFlags
hsc_dflags HscEnv
env) { log_action :: LogAction
DynFlags.log_action = Logger -> LogAction
Env.log_action Logger
logger }) HscEnv
env
#endif
pushLogHook :: (LogAction -> LogAction) -> Logger -> Logger
pushLogHook :: (LogAction -> LogAction) -> Logger -> Logger
pushLogHook LogAction -> LogAction
f Logger
logger =
#if MIN_VERSION_ghc(9,2,0)
Logger.pushLogHook f logger
#else
Logger
logger { log_action :: LogAction
Env.log_action = LogAction -> LogAction
f (Logger -> LogAction
Env.log_action Logger
logger) }
#endif
#if MIN_VERSION_ghc(9,0,0)
type LogActionCompat = DynFlags -> WarnReason -> Severity -> SrcSpan -> PrintUnqualified -> SDoc -> IO ()
logActionCompat :: LogActionCompat -> LogAction
logActionCompat logAction dynFlags wr severity loc = logAction dynFlags wr severity loc alwaysQualify
#else
type LogActionCompat = DynFlags -> WarnReason -> Severity -> SrcSpan -> PrintUnqualified -> SDoc -> IO ()
logActionCompat :: LogActionCompat -> LogAction
logActionCompat :: LogActionCompat -> LogAction
logActionCompat LogActionCompat
logAction DynFlags
dynFlags WarnReason
wr Severity
severity SrcSpan
loc PprStyle
style = LogActionCompat
logAction DynFlags
dynFlags WarnReason
wr Severity
severity SrcSpan
loc (PprStyle -> PrintUnqualified
queryQual PprStyle
style)
#endif