Skip to main content

Log Saver Formatter

The log saver formatter writes test logs to a given path on disk. Note that Sandwich already writes logs to disk by default, as configured by the optionsSavedLogLevel option, so this is primarily useful when you want to save logs to another location, or with a different log level, or with a different formatter from the global one.

It is a "secondary" formatter in the sense that it doesn't write to stdout or stderr, so it can run in the background while another formatter (such as the terminal UI or print formatters) monopolize the output streams.

Usage#

This formatter must be included manually in the optionsFormatters of your sandwich options.

import Test.Sandwich.Formatters.LogSaver
main :: IO ()
main = runSandwich options myTests
where
options = defaultOptions {
optionsFormatters = [SomeFormatter defaultLogSaverFormatter]
}

Configuration#

The main option to set is the logSaverPath, which controls where the logs are written. This can be set to either an absolute path, or a path relative to the test run root.

You can see the other configuration options in the documentation.