propellor-5.1.0: property-based host configuration management in haskell

Safe HaskellNone



This module handles all display of output to the console when propellor is ensuring Properties.

When two threads both try to display a message concurrently, the messages will be displayed sequentially.



data Trace Source #

Serializable tracing. Export `PROPELLOR_TRACE=1` in the environment to make propellor emit these to stdout, in addition to its other output.

parseTrace :: String -> Maybe Trace Source #

Given a line read from propellor, if it's a serialized Trace, parses it.

getMessageHandle :: IO MessageHandle Source #

Gets the global MessageHandle.

isConsole :: MessageHandle -> Bool Source #

forceConsole :: IO () Source #

Force console output. This can be used when stdout is not directly connected to a console, but is eventually going to be displayed at a console.

actionMessage :: (MonadIO m, MonadMask m, ActionResult r, ToResult r) => Desc -> m r -> m r Source #

Shows a message while performing an action, with a colored status display.

actionMessageOn :: (MonadIO m, MonadMask m, ActionResult r, ToResult r) => HostName -> Desc -> m r -> m r Source #

Shows a message while performing an action on a specified host, with a colored status display.

infoMessage :: MonadIO m => [String] -> m () Source #

errorMessage :: MonadIO m => String -> m a Source #

Displays the error message in red, and throws an exception.

When used inside a property, the exception will make the current property fail. Propellor will continue to the next property.

stopPropellorMessage :: MonadIO m => String -> m a Source #

Like errorMessage, but throws a StopPropellorException, preventing propellor from continuing to the next property.

Think twice before using this. Is the problem so bad that propellor cannot try to ensure other properties? If not, use errorMessage instead.

messagesDone :: IO () Source #

Called when all messages about properties have been printed.

createProcessConcurrent :: CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ConcurrentProcessHandle) Source #

Wrapper around createProcess that prevents multiple processes that are running concurrently from writing to stdout/stderr at the same time.

If the process does not output to stdout or stderr, it's run by createProcess entirely as usual. Only processes that can generate output are handled specially:

A process is allowed to write to stdout and stderr in the usual way, assuming it can successfully take the output lock.

When the output lock is held (ie, by another concurrent process, or because outputConcurrent is being called at the same time), the process is instead run with its stdout and stderr redirected to a buffer. The buffered output will be displayed as soon as the output lock becomes free.

Currently only available on Unix systems, not Windows.

withConcurrentOutput :: (MonadIO m, MonadMask m) => m a -> m a Source #

Use this around any actions that use outputConcurrent or createProcessConcurrent

This is necessary to ensure that buffered concurrent output actually gets displayed before the program exits.