hls-plugin-api-2.9.0.0: Haskell Language Server API for plugin communication

Safe Haskell | None
Language | GHC2021

Ide.Logger

Description

This is a compatibility module that abstracts over the concrete choice of logging framework so users can plug in whatever framework they want to.

Synopsis

- data Priority
  - = Debug
  - | Info
  - | Warning
  - | Error
- newtype Recorder msg = Recorder {
  - logger_ :: forall (m :: Type -> Type). MonadIO m => msg -> m ()
  }
- data WithPriority a = WithPriority {
  - priority :: Priority
  - callStack_ :: CallStack
  - payload :: a
  }
- logWith :: (HasCallStack, MonadIO m) => Recorder (WithPriority msg) -> Priority -> msg -> m ()
- cmap :: (a -> b) -> Recorder b -> Recorder a
- cmapIO :: (a -> IO b) -> Recorder b -> Recorder a
- cfilter :: (a -> Bool) -> Recorder a -> Recorder a
- withFileRecorder :: MonadUnliftIO m => FilePath -> Maybe [LoggingColumn] -> (Either IOException (Recorder (WithPriority (Doc d))) -> m a) -> m a
- makeDefaultStderrRecorder :: MonadIO m => Maybe [LoggingColumn] -> m (Recorder (WithPriority (Doc a)))
- makeDefaultHandleRecorder :: MonadIO m => Maybe [LoggingColumn] -> Lock -> Handle -> m (Recorder (WithPriority (Doc a)))
- data LoggingColumn
  - = TimeColumn
  - | ThreadIdColumn
  - | PriorityColumn
  - | DataColumn
  - | SourceLocColumn
- cmapWithPrio :: (a -> b) -> Recorder (WithPriority b) -> Recorder (WithPriority a)
- withBacklog :: (v -> Recorder a) -> IO (Recorder a, v -> IO ())
- lspClientMessageRecorder :: LanguageContextEnv config -> Recorder (WithPriority Text)
- lspClientLogRecorder :: LanguageContextEnv config -> Recorder (WithPriority Text)
- module Prettyprinter
- renderStrict :: SimpleDocStream ann -> Text
- toCologActionWithPrio :: forall (m :: Type -> Type) msg. (MonadIO m, HasCallStack) => Recorder (WithPriority msg) -> LogAction m (WithSeverity msg)
- defaultLoggingColumns :: [LoggingColumn]

# Documentation

data Priority #

Constructors

Debug | Verbose debug logging.
Info | Useful information in case an error has to be understood.
Warning | These error messages should not occur in a expected usage, and should be investigated.
Error | Such log messages must never occur in expected usage.

#### Instances

Instances details

Bounded Priority # |
Instance details Defined in Ide.Logger Methods minBound :: Priority # maxBound :: Priority #
Enum Priority # |
Instance details Defined in Ide.Logger Methods succ :: Priority -> Priority # pred :: Priority -> Priority # toEnum :: Int -> Priority # fromEnum :: Priority -> Int # enumFrom :: Priority -> [Priority] # enumFromThen :: Priority -> Priority -> [Priority] # enumFromTo :: Priority -> Priority -> [Priority] # enumFromThenTo :: Priority -> Priority -> Priority -> [Priority] #
Read Priority # |
Instance details Defined in Ide.Logger Methods readsPrec :: Int -> ReadS Priority # readList :: ReadS [Priority] # readPrec :: ReadPrec Priority # readListPrec :: ReadPrec [Priority] #
Show Priority # |
Instance details Defined in Ide.Logger Methods showsPrec :: Int -> Priority -> ShowS # show :: Priority -> String # showList :: [Priority] -> ShowS #
Eq Priority # |
Instance details Defined in Ide.Logger Methods (==) :: Priority -> Priority -> Bool # (/=) :: Priority -> Priority -> Bool #
Ord Priority # |
Instance details Defined in Ide.Logger Methods compare :: Priority -> Priority -> Ordering # (<) :: Priority -> Priority -> Bool # (<=) :: Priority -> Priority -> Bool # (>) :: Priority -> Priority -> Bool # (>=) :: Priority -> Priority -> Bool # max :: Priority -> Priority -> Priority # min :: Priority -> Priority -> Priority #

newtype Recorder msg #

Note that this is logging actions _of the program_, not of the user. You shouldn't call warning/error if the user has caused an error, only if our code has gone wrong and is itself erroneous (e.g. we threw an exception).

Constructors

Recorder |

Fields

- logger_ :: forall (m :: Type -> Type). MonadIO m => msg -> m ()

#### Instances

Instances details

Contravariant Recorder # |
Instance details Defined in Ide.Logger Methods contramap :: (a' -> a) -> Recorder a -> Recorder a' # (>$) :: b -> Recorder b -> Recorder a #
Monoid (Recorder msg) # |
Instance details Defined in Ide.Logger Methods mempty :: Recorder msg # mappend :: Recorder msg -> Recorder msg -> Recorder msg # mconcat :: [Recorder msg] -> Recorder msg #
Semigroup (Recorder msg) # |
Instance details Defined in Ide.Logger Methods (<>) :: Recorder msg -> Recorder msg -> Recorder msg # sconcat :: NonEmpty (Recorder msg) -> Recorder msg # stimes :: Integral b => b -> Recorder msg -> Recorder msg #

data WithPriority a #

Constructors

WithPriority |

Fields

- priority :: Priority
- callStack_ :: CallStack
- payload :: a

#### Instances

Instances details

Functor WithPriority # |
Instance details Defined in Ide.Logger Methods fmap :: (a -> b) -> WithPriority a -> WithPriority b # (<$) :: a -> WithPriority b -> WithPriority a #

logWith :: (HasCallStack, MonadIO m) => Recorder (WithPriority msg) -> Priority -> msg -> m () #

cmap :: (a -> b) -> Recorder b -> Recorder a #

cmapIO :: (a -> IO b) -> Recorder b -> Recorder a #

cfilter :: (a -> Bool) -> Recorder a -> Recorder a #

withFileRecorder #

Arguments

:: MonadUnliftIO m |
=> FilePath | Log file path.
-> Maybe [LoggingColumn] | logging columns to display. `Nothing` uses `defaultLoggingColumns`
-> (Either IOException (Recorder (WithPriority (Doc d))) -> m a) | action given a recorder, or the exception if we failed to open the file
-> m a |

makeDefaultStderrRecorder :: MonadIO m => Maybe [LoggingColumn] -> m (Recorder (WithPriority (Doc a))) #

makeDefaultHandleRecorder #

Arguments

:: MonadIO m |
=> Maybe [LoggingColumn] | built-in logging columns to display. Nothing uses the default
-> Lock | lock to take when outputting to handle
-> Handle | handle to output to
-> m (Recorder (WithPriority (Doc a))) |

data LoggingColumn #

Constructors

TimeColumn |
ThreadIdColumn |
PriorityColumn |
DataColumn |
SourceLocColumn |

cmapWithPrio :: (a -> b) -> Recorder (WithPriority b) -> Recorder (WithPriority a) #

withBacklog :: (v -> Recorder a) -> IO (Recorder a, v -> IO ()) #

Given a `Recorder` that requires an argument, produces a `Recorder` that queues up messages until the argument is provided using the callback, at which point it sends the backlog and begins functioning normally.

lspClientMessageRecorder :: LanguageContextEnv config -> Recorder (WithPriority Text) #

Creates a recorder that sends logs to the LSP client via `window/showMessage` notifications.

lspClientLogRecorder :: LanguageContextEnv config -> Recorder (WithPriority Text) #

Creates a recorder that sends logs to the LSP client via `window/logMessage` notifications.

module Prettyprinter

renderStrict :: SimpleDocStream ann -> Text #

`(`renderStrict` sdoc)` takes the output `sdoc` from a rendering function and transforms it to strict text.

toCologActionWithPrio :: forall (m :: Type -> Type) msg. (MonadIO m, HasCallStack) => Recorder (WithPriority msg) -> LogAction m (WithSeverity msg) #

defaultLoggingColumns :: [LoggingColumn] #