-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
make logging work with trimming #55166
Conversation
also implement a --strict mode where generating a dynamic dispatch becomes a compile time error
…Also refactor the runtime to only have one option
Union split test gives the wrong result
Note this is a PR against #55047 Co-authored by: Gabriel Baraldi <[email protected]>
…. hacks) A lot of these changes will not be directly upstreamable, but this sketches out the direction we'll have to go in to type-stabilize these interfaces.
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.
Thanks for doing this! Constraining the types seems to be the only hope for making the logging system play nice with invalidations and static compilation. It might be possible to remove some of the @invokelatest
s now?
I wanted to do a version of this during the invalidation hunt during 1.6 development, but I was concerned that it would be a breaking change. Is the idea that the new normalization methods give us a way to impose constraints in a way that allows packages to be fixed?
This seems like a change that could be submitted independently, and a PkgEval run might shake out any issues early.
Convert the provided `value` into a String which will be passed to | ||
`handle_message` for printing. | ||
|
||
Applied to all kwargs seen by handle message, except `maxlog` which is not |
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.
Applied to all kwargs seen by handle message, except `maxlog` which is not | |
Applied to all kwargs seen by `handle_message`, except `maxlog` which is not |
""" | ||
normalize_message(logger, context, message) | ||
""" | ||
normalize_message(logger::AbstractLogger, context::Any, message::Any) = message |
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.
normalize_message(logger::AbstractLogger, context::Any, message::Any) = message | |
normalize_message(logger::AbstractLogger, context::Any, message::Any) = convert(Union{String,Base.AnnotatedString{String}}, message)::Union{String,Base.AnnotatedString{String}} |
Otherwise aren't you at risk for an unclear MethodError
or that people will address this by adding new handle_message
methods that accept something besides Union{String,Base.AnnotatedString{String}}
? Whereas this version at least makes the "contract" clearer. (One could of course use string
instead, it's the type-assert that seems most important.)
Likewise with normalize_kwarg
below.
See also #40820. I have also seen "non-conforming" types in the wild. |
f069cd2
to
d9e09c3
Compare
aff2464
to
6657750
Compare
583f795
to
aa8b031
Compare
The
Unfortunately, no. As-is, this PR expects to have the logger type inferrable (that's what makes invalidating That means this PR is cheating though, since it can resolve the multiple dispatch of
Part of that problem is that loggers in general can serialize objects in "any" way. One way to tackle that problem might be to split the "serialization type" from the "logger type", so that the combinatorics improve? If we can do that without breaking the ecosystem, that would be my vote for a path forward I think.
Totally agreed - Seems like the way to go There was already an accidental breakage in 1.6 for custom log levels, which has lead to some type piracy in the ecosystem: https://github.com/chmerdon/GradientRobustMultiPhysics.jl/blob/ef6a7c81ee395a1a33a5bd90bd28e10d4bba4ca0/src/logging.jl#L2-L19, so that will need a bit of clean up too |
Oof, sorry about that 1.6 breakage. I wonder why it wasn't picked up by PkgEval. I guess it's not technically piracy because they own |
Hah, that is true - but it does create a composability problem since now the CustomLevel doesn't work with a new custom logger Thankfully in this case, I think the interface for custom log levels is pretty easy-to-define (and also "single dispatch", since the behavior within that interface shouldn't really depend on the logger) |
94ac125
to
d596feb
Compare
8e1b808
to
5a95814
Compare
Looks like this is significantly conflicted and outdated |
Note this is against #55047.
@topolarity I moved this to a separate branch since it has test failures and can be finished after merging #55047.