-
Couldn't load subscription status.
- Fork 721
Cabal library: allow setting the logging handle #11077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
0b6b552 to
4ed7d13
Compare
|
It does occur to me, that the next step after this PR is to use a proper logging framework (ie. a contravariant logger) within the Cabal library. That would be even more general than the |
3253ca2 to
4f85396
Compare
|
The problem with using a logging framework is bootstrapping. |
30af75a to
cb24b34
Compare
It seems that you could add a single-file implementation of a logging library which |
5ba03ea to
afd8839
Compare
|
I have added a changelog entry under |
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 commit modifies Verbosity as follows:
1. The old Verbosity datatype becomes VerbosityFlags. This is what
gets passed in the command-line interface, e.g. when running a
Setup executable.
2. The new Verbosity datatype contains VerbosityFlags together with
VerbosityHandles, which specify where to redirect stdout/stderr.
Crucially, this allows us to get rid of the
isJust (useLoggingHandle options)
condition in 'getSetupMethod', which forced us to use the cabal-install
"act as setup" mechanism instead of directly calling Cabal library
functions.
Fixes #9987
afd8839 to
489fb11
Compare
|
Current TODOs:
|
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.