| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Shrun.Configuration.Data.FileLogging
Contents
Synopsis
- data FileLogInitP (p :: ConfigPhase) = MkFileLogInitP {
- path :: FileLogPathF p
- sizeMode :: ConfigPhaseF p FileSizeMode
- data FileLogOpened = MkFileLogOpened {}
- data FileLoggingP (p :: ConfigPhase) = MkFileLoggingP {
- file :: FileLogFileF p
- commandNameTrunc :: ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
- deleteOnSuccess :: SwitchF p DeleteOnSuccessSwitch
- lineTrunc :: LineTruncF p
- mode :: ConfigPhaseF p FileMode
- multi :: FileLogMultiF p
- stripControl :: ConfigPhaseF p FileLogStripControl
- type FileLoggingArgs = FileLoggingP 'ConfigPhaseArgs
- type FileLoggingToml = FileLoggingP 'ConfigPhaseToml
- type FileLoggingMerged = FileLoggingP 'ConfigPhaseMerged
- type FileLoggingEnv = FileLoggingP 'ConfigPhaseEnv
- newtype DeleteOnSuccessSwitch = MkDeleteOnSuccessSwitch Bool
- newtype FileLogMultiSwitch = MkFileLogMultiSwitch Bool
- mergeFileLogging :: (HasCallStack, MonadCatch m, MonadIORef m, MonadTerminal m) => NESeq CommandP1 -> IORef DetectResult -> FileLoggingArgs -> Maybe FileLoggingToml -> m (Maybe FileLoggingMerged)
- withFileLoggingEnv :: (HasCallStack, MonadAtomic m, MonadFileWriter m, MonadHandleWriter m, MonadMask m, MonadPathReader m, MonadPathWriter m, MonadPosixFiles m, MonadTerminal m) => Maybe FileLoggingMerged -> (Maybe FileLoggingEnv -> m a) -> m a
- createMultiLogFile :: (HasCallStack, MonadAtomic m, MonadHandleWriter m, MonadPathReader m, MonadPosixFiles m, MonadThrow m) => TVar Word16 -> FileMode -> OsPath -> m OsPath
Documentation
data FileLogInitP (p :: ConfigPhase) Source #
Initial file log params, for usage before we create the final Env.
Constructors
| MkFileLogInitP | |
Fields
| |
Instances
| (k ~ A_Lens, a ~ FileLogPathF p, b ~ FileLogPathF p) => LabelOptic "path" k (FileLogInitP p) (FileLogInitP p) a b Source # | |
Defined in Shrun.Configuration.Data.FileLogging Methods labelOptic :: Optic k NoIx (FileLogInitP p) (FileLogInitP p) a b Source # | |
| (k ~ A_Lens, a ~ ConfigPhaseF p FileSizeMode, b ~ ConfigPhaseF p FileSizeMode) => LabelOptic "sizeMode" k (FileLogInitP p) (FileLogInitP p) a b Source # | |
Defined in Shrun.Configuration.Data.FileLogging Methods labelOptic :: Optic k NoIx (FileLogInitP p) (FileLogInitP p) a b Source # | |
data FileLogOpened Source #
Params after we have opened the file for logging.
Constructors
| MkFileLogOpened | |
Instances
| (k ~ A_Lens, a ~ LockedHandleW, b ~ LockedHandleW) => LabelOptic "handle" k FileLogOpened FileLogOpened a b Source # | |
Defined in Shrun.Configuration.Data.FileLogging Methods labelOptic :: Optic k NoIx FileLogOpened FileLogOpened a b Source # | |
| (k ~ A_Lens, a ~ OsPath, b ~ OsPath) => LabelOptic "path" k FileLogOpened FileLogOpened a b Source # | |
Defined in Shrun.Configuration.Data.FileLogging Methods labelOptic :: Optic k NoIx FileLogOpened FileLogOpened a b Source # | |
| (k ~ A_Lens, a ~ TBQueue FileLog, b ~ TBQueue FileLog) => LabelOptic "queue" k FileLogOpened FileLogOpened a b Source # | |
Defined in Shrun.Configuration.Data.FileLogging Methods labelOptic :: Optic k NoIx FileLogOpened FileLogOpened a b Source # | |
data FileLoggingP (p :: ConfigPhase) Source #
Holds file logging config.
Constructors
| MkFileLoggingP | |
Fields
| |
Instances
type FileLoggingEnv = FileLoggingP 'ConfigPhaseEnv Source #
newtype DeleteOnSuccessSwitch Source #
Switch for deleting the log file upon success.
Constructors
| MkDeleteOnSuccessSwitch Bool |
Instances
newtype FileLogMultiSwitch Source #
Switch for logging to multiple files.
Constructors
| MkFileLogMultiSwitch Bool |
Instances
mergeFileLogging :: (HasCallStack, MonadCatch m, MonadIORef m, MonadTerminal m) => NESeq CommandP1 -> IORef DetectResult -> FileLoggingArgs -> Maybe FileLoggingToml -> m (Maybe FileLoggingMerged) Source #
Merges args and toml configs.
withFileLoggingEnv :: (HasCallStack, MonadAtomic m, MonadFileWriter m, MonadHandleWriter m, MonadMask m, MonadPathReader m, MonadPathWriter m, MonadPosixFiles m, MonadTerminal m) => Maybe FileLoggingMerged -> (Maybe FileLoggingEnv -> m a) -> m a Source #
Given merged FileLogging config, constructs a FileLoggingEnv and calls the continuation.
Misc
createMultiLogFile :: (HasCallStack, MonadAtomic m, MonadHandleWriter m, MonadPathReader m, MonadPosixFiles m, MonadThrow m) => TVar Word16 -> FileMode -> OsPath -> m OsPath Source #
Like createLogFile, but for multi logs, which has different semantics.
While we allow overwriting / appending to existing files, what we absolutely do not want to allow is two shrun commands actively logging to the same file. This would mean logs get jumbled up.
Therefore, if we encounter an extant file, we use the TVar counter to append a number. This index is unique across all shrun commands, hence we will not have interference.