Cabal library: allow setting the logging handle #11077
Draft
+1,304
−885
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
Verbosityas follows:Verbositydatatype becomesVerbosityFlags. This is what gets passed in the command-line interface, e.g. when running a Setup executable.Verbositydatatype containsVerbosityFlagstogether 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
VerbosityFlagsdata type (which, recall, is whatVerbosityused to be):Ordinstance ofVerbosityFlagshas been removed.Comparing verbosity levels is now done through the
Ordinstance onVerbosityLevel, viaverbosityLevel :: Verbosity -> VerbosityLevel.Eqinstance ofVerbosityFlagsnow takes into account all the fields, and not only the verbosity level.EnumandBoundedinstances ofVerbosityFlagshave been removed.Users are again encouraged to go through
VerbosityLevelinstead.In addition, the
modifyVerbosityfunction 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
makeVerbosefunction which increases the "normal" verbosity level to "verbose" and leaves other verbosity levels unchanged.significance: significantin the changelog file.