Safe Haskell | None |
---|---|
Language | Haskell2010 |
GHC.Utils.Logger
Description
Logger
The Logger is an configurable entity that is used by the compiler to output messages on the console (stdout, stderr) and in dump files.
The behaviour of default Logger returned by initLogger
can be modified with
hooks. The compiler itself uses hooks in multithreaded code (--make) and it
is also probably used by ghc-api users (IDEs, etc.).
In addition to hooks, the Logger supports LogFlags: basically a subset of the command-line flags that control the logger behaviour at a higher level than hooks.
- Hooks are used to define how to generate a infowarningerror/dump messages
- LogFlags are used to decide when and how to generate messages
Synopsis
- data Logger
- class HasLogger (m :: Type -> Type) where
- class ContainsLogger t where
- extractLogger :: t -> Logger
- initLogger :: IO Logger
- type LogAction = LogFlags -> MessageClass -> SrcSpan -> SDoc -> IO ()
- type DumpAction = LogFlags -> PprStyle -> DumpFlag -> String -> DumpFormat -> SDoc -> IO ()
- type TraceAction a = LogFlags -> String -> SDoc -> a -> a
- data DumpFormat
- popLogHook :: Logger -> Logger
- pushLogHook :: (LogAction -> LogAction) -> Logger -> Logger
- popDumpHook :: Logger -> Logger
- pushDumpHook :: (DumpAction -> DumpAction) -> Logger -> Logger
- popTraceHook :: Logger -> Logger
- pushTraceHook :: (forall a. TraceAction a -> TraceAction a) -> Logger -> Logger
- makeThreadSafe :: Logger -> IO Logger
- data LogFlags = LogFlags {
- log_default_user_context :: SDocContext
- log_default_dump_context :: SDocContext
- log_dump_flags :: !(EnumSet DumpFlag)
- log_show_caret :: !Bool
- log_show_warn_groups :: !Bool
- log_enable_timestamps :: !Bool
- log_dump_to_file :: !Bool
- log_dump_dir :: !(Maybe FilePath)
- log_dump_prefix :: !FilePath
- log_dump_prefix_override :: !(Maybe FilePath)
- log_with_ways :: !Bool
- log_enable_debug :: !Bool
- log_verbosity :: !Int
- log_ways :: !(Maybe Ways)
- defaultLogFlags :: LogFlags
- log_dopt :: DumpFlag -> LogFlags -> Bool
- log_set_dopt :: DumpFlag -> LogFlags -> LogFlags
- setLogFlags :: Logger -> LogFlags -> Logger
- updateLogFlags :: Logger -> (LogFlags -> LogFlags) -> Logger
- logFlags :: Logger -> LogFlags
- logHasDumpFlag :: Logger -> DumpFlag -> Bool
- logVerbAtLeast :: Logger -> Int -> Bool
- jsonLogAction :: LogAction
- putLogMsg :: Logger -> LogAction
- defaultLogAction :: LogAction
- defaultLogActionHPrintDoc :: LogFlags -> Bool -> Handle -> SDoc -> IO ()
- defaultLogActionHPutStrDoc :: LogFlags -> Bool -> Handle -> SDoc -> IO ()
- logMsg :: Logger -> MessageClass -> SrcSpan -> SDoc -> IO ()
- logDumpMsg :: Logger -> String -> SDoc -> IO ()
- defaultDumpAction :: DumpCache -> LogAction -> DumpAction
- putDumpFile :: Logger -> DumpAction
- putDumpFileMaybe :: Logger -> DumpFlag -> String -> DumpFormat -> SDoc -> IO ()
- putDumpFileMaybe' :: Logger -> NamePprCtx -> DumpFlag -> String -> DumpFormat -> SDoc -> IO ()
- withDumpFileHandle :: DumpCache -> LogFlags -> DumpFlag -> (Maybe Handle -> IO ()) -> IO ()
- touchDumpFile :: Logger -> DumpFlag -> IO ()
- logDumpFile :: Logger -> PprStyle -> DumpFlag -> String -> DumpFormat -> SDoc -> IO ()
- defaultTraceAction :: TraceAction a
- putTraceMsg :: Logger -> TraceAction a
- loggerTraceFlushUpdate :: Logger -> (IO () -> IO ()) -> Logger
- loggerTraceFlush :: Logger -> IO ()
- logTraceMsg :: Logger -> String -> SDoc -> a -> a
Documentation
class HasLogger (m :: Type -> Type) where #
Instances
HasLogger CoreM # | |
Defined in GHC.Core.Opt.Monad | |
HasLogger SimplM # | |
Defined in GHC.Core.Opt.Simplify.Monad | |
HasLogger Hsc # | |
Defined in GHC.Driver.Env.Types | |
HasLogger Ghc # | |
Defined in GHC.Driver.Monad | |
ContainsLogger env => HasLogger (IOEnv env) # | |
Defined in GHC.Data.IOEnv | |
MonadIO m => HasLogger (GhcT m) # | |
Defined in GHC.Driver.Monad |
class ContainsLogger t where #
Methods
extractLogger :: t -> Logger #
Instances
ContainsLogger (Env gbl lcl) # | |
Defined in GHC.Tc.Types Methods extractLogger :: Env gbl lcl -> Logger # |
Logger setup
initLogger :: IO Logger #
type DumpAction = LogFlags -> PprStyle -> DumpFlag -> String -> DumpFormat -> SDoc -> IO () #
type TraceAction a = LogFlags -> String -> SDoc -> a -> a #
data DumpFormat #
Format of a dump
Dump formats are loosely defined: dumps may contain various additional
headers and annotations and they may be partial. DumpFormat
is mainly a hint
(e.g. for syntax highlighters).
Constructors
FormatHaskell | Haskell |
FormatCore | Core |
FormatSTG | STG |
FormatByteCode | ByteCode |
FormatCMM | Cmm |
FormatASM | Assembly code |
FormatC | C code/header |
FormatLLVM | LLVM bytecode |
FormatJS | JavaScript code |
FormatText | Unstructured dump |
Instances
Show DumpFormat # | |
Defined in GHC.Utils.Logger Methods showsPrec :: Int -> DumpFormat -> ShowS # show :: DumpFormat -> String # showList :: [DumpFormat] -> ShowS # | |
Eq DumpFormat # | |
Defined in GHC.Utils.Logger |
Hooks
popLogHook :: Logger -> Logger #
Pop a log hook
popDumpHook :: Logger -> Logger #
Pop a dump hook
pushDumpHook :: (DumpAction -> DumpAction) -> Logger -> Logger #
Push a dump hook
popTraceHook :: Logger -> Logger #
Pop a trace hook
pushTraceHook :: (forall a. TraceAction a -> TraceAction a) -> Logger -> Logger #
Push a trace hook
makeThreadSafe :: Logger -> IO Logger #
Make the logger thread-safe
Flags
Logger flags
Constructors
LogFlags | |
Fields
|
Default LogFlags
log_set_dopt :: DumpFlag -> LogFlags -> LogFlags #
Enable a DumpFlag
setLogFlags :: Logger -> LogFlags -> Logger #
Set LogFlags
logHasDumpFlag :: Logger -> DumpFlag -> Bool #
Test if a DumpFlag is set
logVerbAtLeast :: Logger -> Int -> Bool #
Test if verbosity is >= to the given value
Logging
defaultLogActionHPrintDoc :: LogFlags -> Bool -> Handle -> SDoc -> IO () #
Like defaultLogActionHPutStrDoc
but appends an extra newline.
defaultLogActionHPutStrDoc :: LogFlags -> Bool -> Handle -> SDoc -> IO () #
The boolean arguments let's the pretty printer know if it can optimize indent by writing ascii ' ' characters without going through decoding.
Dumping
defaultDumpAction :: DumpCache -> LogAction -> DumpAction #
Default action for dumpAction
hook
putDumpFile :: Logger -> DumpAction #
Dump something
putDumpFileMaybe :: Logger -> DumpFlag -> String -> DumpFormat -> SDoc -> IO () #
Dump if the given DumpFlag is set
putDumpFileMaybe' :: Logger -> NamePprCtx -> DumpFlag -> String -> DumpFormat -> SDoc -> IO () #
Dump if the given DumpFlag is set
Unlike putDumpFileMaybe
, has a NamePprCtx argument
touchDumpFile :: Logger -> DumpFlag -> IO () #
Ensure that a dump file is created even if it stays empty
logDumpFile :: Logger -> PprStyle -> DumpFlag -> String -> DumpFormat -> SDoc -> IO () #
Dump something
Tracing
defaultTraceAction :: TraceAction a #
Default action for traceAction
hook
putTraceMsg :: Logger -> TraceAction a #
Trace something
loggerTraceFlushUpdate :: Logger -> (IO () -> IO ()) -> Logger #
Set the trace flushing function
The currently set trace flushing function is passed to the updating function
loggerTraceFlush :: Logger -> IO () #
Calls the trace flushing function
logTraceMsg :: Logger -> String -> SDoc -> a -> a #
Log a trace message