Skip to content

deprecate global and process verbosity #290

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

Merged
merged 2 commits into from
Feb 21, 2022

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Feb 9, 2022

motivation: fine grained control over verbosity setting and handling of logging

changes:

  • deprecate global verbosity flag
  • deprecate Process verbosity attribute in favor of an optional logging handler (closure)

@tomerd
Copy link
Contributor Author

tomerd commented Feb 9, 2022

afaict this is only used by SwiftPM, which is addressed in swiftlang/swift-package-manager#4109

@tomerd
Copy link
Contributor Author

tomerd commented Feb 9, 2022

Self.loggingHandler != nil
}

public static var loggingHandler: ((String) -> Void)? = nil
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in love with this static, but it is useful to be able to set this globally in SwiftPM instead of on every process invocation. open to other ideas and opinions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also thread unsafe

Copy link
Contributor Author

@tomerd tomerd Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea i think i am going to just remove it and let the clients deal with setting a handler at the instance call site level. they can always create their own wrapper

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, you can also always use a lock... but it doesn't seem like a great idea anyway

Copy link
Contributor Author

@tomerd tomerd Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, I dont like this global pattern anyway. lets see how much hassle it is to do it instance level in SwiftPM

Copy link
Contributor Author

@tomerd tomerd Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh. its quite a bit of a hassle unfortunately. I added lock for now. @weissi :/ ptal

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@tomerd
Copy link
Contributor Author

tomerd commented Feb 12, 2022

3 similar comments
@tomerd
Copy link
Contributor Author

tomerd commented Feb 14, 2022

@tomerd
Copy link
Contributor Author

tomerd commented Feb 17, 2022

@tomerd
Copy link
Contributor Author

tomerd commented Feb 17, 2022

stdoutStream <<< arguments.map({ $0.spm_shellEscaped() }).joined(separator: " ") <<< "\n"
stdoutStream.flush()
if let loggingHandler = self.loggingHandler {
loggingHandler(arguments.map({ $0.spm_shellEscaped() }).joined(separator: " "))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\n not needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not any more, it was for the stream itself. the handler will decide what to do with it now

@tomerd tomerd force-pushed the refactor/verbosity branch from 7c44b2d to c282b4a Compare February 18, 2022 21:23
motivation: fine grained control over verbosity setting and handling of logging

changes:
* deprecate global verbosity flag
* deprecate Process verbosity attribute in favor of an optional logging handler (closure)
@tomerd tomerd force-pushed the refactor/verbosity branch from c282b4a to a79476b Compare February 18, 2022 21:23
@tomerd
Copy link
Contributor Author

tomerd commented Feb 18, 2022

@swift-ci please test

@tomerd tomerd merged commit c2a3c4f into swiftlang:main Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants