GHC.Utils.Logger

ghc-9.2.0.20210422: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.Utils.Logger

Contents

- Hooks
- Logging
- Dumping
- Tracing

Description

Logger

Synopsis

- data Logger
- initLogger :: IO Logger
- class HasLogger m where
  - getLogger :: m Logger
- class ContainsLogger t where
  - extractLogger :: t -> Logger
- type LogAction = DynFlags -> WarnReason -> Severity -> SrcSpan -> SDoc -> IO ()
- type DumpAction = DynFlags -> PprStyle -> DumpFlag -> String -> DumpFormat -> SDoc -> IO ()
- type TraceAction a = DynFlags -> String -> SDoc -> a -> a
- data DumpFormat
  - = FormatHaskell
  - | FormatCore
  - | FormatSTG
  - | FormatByteCode
  - | FormatCMM
  - | FormatASM
  - | FormatC
  - | FormatLLVM
  - | FormatText
- putLogMsg :: Logger -> LogAction
- putDumpMsg :: Logger -> DumpAction
- putTraceMsg :: Logger -> TraceAction a
- 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
- jsonLogAction :: LogAction
- defaultLogAction :: LogAction
- defaultLogActionHPrintDoc :: DynFlags -> Bool -> Handle -> SDoc -> IO ()
- defaultLogActionHPutStrDoc :: DynFlags -> Bool -> Handle -> SDoc -> IO ()
- defaultDumpAction :: DumpCache -> LogAction -> DumpAction
- withDumpFileHandle :: DumpCache -> DynFlags -> DumpFlag -> (Maybe Handle -> IO ()) -> IO ()
- touchDumpFile :: Logger -> DynFlags -> DumpFlag -> IO ()
- dumpIfSet :: Logger -> DynFlags -> Bool -> String -> SDoc -> IO ()
- dumpIfSet_dyn :: Logger -> DynFlags -> DumpFlag -> String -> DumpFormat -> SDoc -> IO ()
- dumpIfSet_dyn_printer :: PrintUnqualified -> Logger -> DynFlags -> DumpFlag -> String -> DumpFormat -> SDoc -> IO ()
- defaultTraceAction :: TraceAction a

# Documentation

data Logger Source #

initLogger :: IO Logger Source #

class HasLogger m where Source #

Methods

getLogger :: m Logger Source #

#### Instances

Instances details

HasLogger LlvmM # |
Instance details Defined in GHC.CmmToLlvm.Base Methods getLogger :: LlvmM Logger Source #
HasLogger CoreM # |
Instance details Defined in GHC.Core.Opt.Monad Methods getLogger :: CoreM Logger Source #
HasLogger SimplM # |
Instance details Defined in GHC.Core.Opt.Simplify.Monad Methods getLogger :: SimplM Logger Source #
HasLogger Hsc # |
Instance details Defined in GHC.Driver.Env.Types Methods getLogger :: Hsc Logger Source #
HasLogger Ghc # |
Instance details Defined in GHC.Driver.Monad Methods getLogger :: Ghc Logger Source #
HasLogger CompPipeline # |
Instance details Defined in GHC.Driver.Pipeline.Monad Methods getLogger :: CompPipeline Logger Source #
ContainsLogger env => HasLogger (IOEnv env) # |
Instance details Defined in GHC.Data.IOEnv Methods getLogger :: IOEnv env Logger Source #
MonadIO m => HasLogger (GhcT m) # |
Instance details Defined in GHC.Driver.Monad Methods getLogger :: GhcT m Logger Source #

class ContainsLogger t where Source #

Methods

extractLogger :: t -> Logger Source #

#### Instances

Instances details

ContainsLogger (Env gbl lcl) # |
Instance details Defined in GHC.Tc.Types Methods extractLogger :: Env gbl lcl -> Logger Source #

type LogAction = DynFlags -> WarnReason -> Severity -> SrcSpan -> SDoc -> IO () Source #

type DumpAction = DynFlags -> PprStyle -> DumpFlag -> String -> DumpFormat -> SDoc -> IO () Source #

type TraceAction a = DynFlags -> String -> SDoc -> a -> a Source #

data DumpFormat Source #

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
FormatText | Unstructured dump

#### Instances

Instances details

Show DumpFormat # |
Instance details Defined in GHC.Utils.Logger Methods showsPrec :: Int -> DumpFormat -> ShowS Source # show :: DumpFormat -> String Source # showList :: [DumpFormat] -> ShowS Source #
Eq DumpFormat # |
Instance details Defined in GHC.Utils.Logger Methods (==) :: DumpFormat -> DumpFormat -> Bool # (/=) :: DumpFormat -> DumpFormat -> Bool #

putLogMsg :: Logger -> LogAction Source #

Log something

putDumpMsg :: Logger -> DumpAction Source #

Dump something

putTraceMsg :: Logger -> TraceAction a Source #

Trace something

# Hooks

popLogHook :: Logger -> Logger Source #

Pop a log hook

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

Push a log hook

popDumpHook :: Logger -> Logger Source #

Pop a dump hook

pushDumpHook :: (DumpAction -> DumpAction) -> Logger -> Logger Source #

Push a dump hook

popTraceHook :: Logger -> Logger Source #

Pop a trace hook

pushTraceHook :: (forall a. TraceAction a -> TraceAction a) -> Logger -> Logger Source #

Push a trace hook

makeThreadSafe :: Logger -> IO Logger Source #

Make the logger thread-safe

# Logging

jsonLogAction :: LogAction Source #

defaultLogAction :: LogAction Source #

defaultLogActionHPrintDoc :: DynFlags -> Bool -> Handle -> SDoc -> IO () Source #

Like `defaultLogActionHPutStrDoc` but appends an extra newline.

defaultLogActionHPutStrDoc :: DynFlags -> Bool -> Handle -> SDoc -> IO () Source #

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 Source #

Default action for `dumpAction` hook

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

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

touchDumpFile :: Logger -> DynFlags -> DumpFlag -> IO () Source #

Ensure that a dump file is created even if it stays empty

dumpIfSet :: Logger -> DynFlags -> Bool -> String -> SDoc -> IO () Source #

dumpIfSet_dyn :: Logger -> DynFlags -> DumpFlag -> String -> DumpFormat -> SDoc -> IO () Source #

A wrapper around `dumpAction`. First check whether the dump flag is set Do nothing if it is unset

dumpIfSet_dyn_printer :: PrintUnqualified -> Logger -> DynFlags -> DumpFlag -> String -> DumpFormat -> SDoc -> IO () Source #

A wrapper around `putDumpMsg`. First check whether the dump flag is set Do nothing if it is unset

Unlike `dumpIfSet_dyn`, has a printer argument

# Tracing

defaultTraceAction :: TraceAction a Source #

Default action for `traceAction` hook