Cabal library: allow setting the logging handle #11077
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Template Α: This PR modifies behaviour or interface.
The goal of this patch is to allow the logging handle to be set when calling Cabal library functions, without having to spawn a separate process and redirect handles. This allows Cabal library functions to be called in a concurrent setting without spawning separate processes.
To achieve this, this PR modifies
Verbosity
as follows:Verbosity
datatype becomesVerbosityFlags
. This is what gets passed in the command-line interface, e.g. when running a Setup executable.Verbosity
datatype containsVerbosityFlags
together withVerbosityHandles
, which specify where to redirect stdout/stderr.Crucially, this allows us to get rid of the
condition in
getSetupMethod
, which forced us to use the cabal-install "act as setup" mechanism instead of directly calling Cabal library functions.Several additional changes have been made in relation to the
VerbosityFlags
data type (which, recall, is whatVerbosity
used to be):Ord
instance ofVerbosityFlags
has been removed.Comparing verbosity levels is now done through the
Ord
instance onVerbosityLevel
, viaverbosityLevel :: Verbosity -> VerbosityLevel
.Eq
instance ofVerbosityFlags
now takes into account all the fields, and not only the verbosity level.Enum
andBounded
instances ofVerbosityFlags
have been removed.Users are again encouraged to go through
VerbosityLevel
instead.In addition, the
modifyVerbosity
function has been removed. It allowed arbitrarily changing the verbosity level, which is undesirable in general (e.g. in practice one wants the "silent" verbosity level to remain "silent").There was only one use site, which was rewritten to use the new
makeVerbose
function which increases the "normal" verbosity level to "verbose" and leaves other verbosity levels unchanged.significance: significant
in the changelog file.