ghc-lib-parser-9.8.1.20231009: The GHC API, decoupled from GHC versions
Safe HaskellSafe-Inferred
LanguageHaskell2010

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.

  1. Hooks are used to define how to generate a infowarningerror/dump messages
  2. LogFlags are used to decide when and how to generate messages
Synopsis

Documentation

data Logger #

class HasLogger m where #

Methods

getLogger :: m Logger #

Instances

Instances details
HasLogger CoreM # 
Instance details

Defined in GHC.Core.Opt.Monad

HasLogger SimplM # 
Instance details

Defined in GHC.Core.Opt.Simplify.Monad

HasLogger Hsc # 
Instance details

Defined in GHC.Driver.Env.Types

Methods

getLogger :: Hsc Logger #

HasLogger Ghc # 
Instance details

Defined in GHC.Driver.Monad

Methods

getLogger :: Ghc Logger #

ContainsLogger env => HasLogger (IOEnv env) # 
Instance details

Defined in GHC.Data.IOEnv

Methods

getLogger :: IOEnv env Logger #

MonadIO m => HasLogger (GhcT m) # 
Instance details

Defined in GHC.Driver.Monad

Methods

getLogger :: GhcT m Logger #

class ContainsLogger t where #

Methods

extractLogger :: t -> Logger #

Instances

Instances details
ContainsLogger (Env gbl lcl) # 
Instance details

Defined in GHC.Tc.Types

Methods

extractLogger :: Env gbl lcl -> Logger #

Logger setup

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

Instances details
Show DumpFormat # 
Instance details

Defined in GHC.Utils.Logger

Eq DumpFormat # 
Instance details

Defined in GHC.Utils.Logger

Hooks

popLogHook :: Logger -> Logger #

Pop a log hook

pushLogHook :: (LogAction -> LogAction) -> Logger -> Logger #

Push 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

data LogFlags #

Logger flags

Constructors

LogFlags 

Fields

defaultLogFlags :: LogFlags #

Default LogFlags

log_dopt :: DumpFlag -> LogFlags -> Bool #

Test if a DumpFlag is enabled

log_set_dopt :: DumpFlag -> LogFlags -> LogFlags #

Enable a DumpFlag

setLogFlags :: Logger -> LogFlags -> Logger #

Set LogFlags

updateLogFlags :: Logger -> (LogFlags -> LogFlags) -> Logger #

Update LogFlags

logFlags :: Logger -> LogFlags #

Logger flags

logHasDumpFlag :: Logger -> DumpFlag -> Bool #

Test if a DumpFlag is set

logVerbAtLeast :: Logger -> Int -> Bool #

Test if verbosity is >= to the given value

Logging

putLogMsg :: Logger -> LogAction #

Log something

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.

logMsg :: Logger -> MessageClass -> SrcSpan -> SDoc -> IO () #

Log something

logDumpMsg :: Logger -> String -> SDoc -> IO () #

Log a dump message (not a dump file)

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

withDumpFileHandle :: DumpCache -> LogFlags -> DumpFlag -> (Maybe Handle -> IO ()) -> IO () #

Run an action with the handle of a DumpFlag if we are outputting to a file, otherwise Nothing.

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