-
Notifications
You must be signed in to change notification settings - Fork 1.4k
command plugins: Add a 'progress' diagnostic message at default verbosity #7256
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
command plugins: Add a 'progress' diagnostic message at default verbosity #7256
Conversation
|
|
||
|
|
||
| /// The plugin emits a progress message. | ||
| case emitProgress(message: String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be extended in future with progress bars or n/m completed prefixes.
| } | ||
|
|
||
|
|
||
| func pluginEmittedProgress(_ message: String) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not clear what is the best option here. Could append to outputData or add a progress array field similar to diagnostics below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, but this needs @neonichu's approval before merging.
|
@swift-ci test |
2389346 to
4ec32b8
Compare
|
Rebased on top of #7262 |
…sity This change adds a 'progress' message to the diagnostics which a plugin can send back to SwiftPM. This message is printed to standard error at the default verbosity level. ### Motivation: Currently, a plugin can write output to standard output or send diagnostics which SwiftPM writes to standard error. If the plugin spawns long-running operations we might want to print progress messages to let the user know that it is still running. The existing options all have compromises: * Anything the plugin prints to its standard output or standard error is echoed to SwiftPM's standard output, but we may want to keep progress information separate from other plugin outputs - the plugin might be called as part of a shell pipeline where a downstream process will consume its output, for example. * The existing diagnostic messages - remark (info), warning and error - are all suppressed at the default verbosity level. * Increasing the level with `-v` causes SwiftPM to print lots of extra logging information from the build, which swamps the plugin info messages. This commit adds a 'progress' message which SwiftPM will print to standard error at the default verbosity level, allowing progress to be shown without polluting standard output or pulling in additional build logging which might not be relevant to the user. ### Modifications: * `Diagnostics.progress` takes a message as a string and passes it to SwiftPM, which prints it to standard error. From the plugin programmer's point of view `Diagnostics.progress` is logically a diagnostics message, however it is a new type in the SwiftPM <-> plugin protocol because extending the existing diagnostics enum would require extensive changes to add a the new message and in many existing cases it would not be relevant. ### Result: A plugin can show the user that it is making progress by printing messages which SwiftPM will echoed to stderr at the default verbosity level.
4ec32b8 to
eb0a203
Compare
|
@swift-ci test |
|
@swift-ci test windows |
This change adds a 'progress' message to the diagnostics which a plugin can send back to SwiftPM. This message is printed to standard error at the default verbosity level.
Motivation:
Currently, a plugin can write output to standard output or send diagnostics which SwiftPM writes to standard error. If the plugin spawns long-running operations we might want to print progress messages to let the user know that it is still running. The existing options all have compromises:
-vcauses SwiftPM to print lots of extra logging information from the build, which swamps the plugin info messages.This commit adds a 'progress' message which SwiftPM will print to standard error at the default verbosity level, allowing progress to be shown without polluting standard output or pulling in additional build logging which might not be relevant to the user.
Modifications:
Diagnostics.progresstakes a message as a string and passes it to SwiftPM, which prints it to standard error.From the plugin programmer's point of view
Diagnostics.progressis logically a diagnostics message, however it is a new type in the SwiftPM <-> plugin protocol because extending the existing diagnostics enum would require extensive changes to add a the new message and in many existing cases it would not be relevant.Result:
A plugin can show the user that it is making progress by printing messages which SwiftPM will echoed to stderr at the default verbosity level.
Example output (
diagnostics-stubis the name of the plugin inPackage.swift):