Skip to content
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

Use Base.CoreLogging #78

Closed
wants to merge 3 commits into from
Closed

Use Base.CoreLogging #78

wants to merge 3 commits into from

Conversation

maleadt
Copy link
Collaborator

@maleadt maleadt commented Dec 15, 2017

Testing out @c42f's new logging infrastructure. Maybe a little early, given how there doesn't seem to be a way to configure the system yet 🙂

Copy link

@c42f c42f left a comment

Choose a reason for hiding this comment

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

Good to see you spinning the wheels! The confusion here probably arises because I haven't yet written any documentation to speak of...

@@ -1,6 +1,7 @@
using Compat

include(joinpath(@__DIR__, "..", "src", "util", "logging.jl"))
using Logging
parse(Bool, get(ENV, "DEBUG", "false")) && global_logger(SimpleLogger(global_logger().stream, Logging.Debug))
Copy link

Choose a reason for hiding this comment

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

Right, there's not a system for configuration yet, but what you're doing here is a very common pattern for this kind of thing which needs some kind of support. Actually I'm not sure I'll even have time for doing something nice for configuration in 1.0 - there's still a lot of other arguably-breaking-but-probably-not-feature-frozen things which need straightening out in Base, while configuration can be done in a package.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I can work with an env flag and global logger for now.

if after_exit[]
raw_print(msg...)
else
print_with_color(color, io, msg...)
Copy link

Choose a reason for hiding this comment

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

Hmm, the current SimpleLogger doesn't support these kind of tricks I'm afraid. Though perhaps it should if it's to be useful in debugging Base.

It's a bit of a tricky issue: it would be nice if general users should expect to be able to install their own AbstractLoggers, but it's not reasonable to expect them to have a fallback path with raw IO.

Maybe the trick is to have a fallback logger in Base (a simplified SimpleLogger, perhaps) which is somehow protected and reinstalled "after" exit, and falls back to ccall somewhat like you have here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Given how plain print is now broken in this case too (ie. you can't print from finalizers), I wouldn't worry about high-level logging not supporting that scenario either. Might look into it when I have another finalizer issue to debug 🙂

@@ -24,7 +24,7 @@ Context() do ctx
@test typeof(LLVM.ref(typ)) == LLVM.API.LLVMTypeRef # untyped

@test typeof(LLVM.IntegerType(LLVM.ref(typ))) == LLVM.IntegerType # type reconstructed
if LLVM.DEBUG
@debug begin # TODO: does this correspond with the loglevel of the LLVM module?
Copy link

Choose a reason for hiding this comment

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

This seems like the wrong use of @debug.

@@ -9,11 +9,9 @@ identify(::Type{LLVMType}, ::Val{K}) where {K} = bug("Unknown type kind $K")

@inline function check(::Type{T}, ref::API.LLVMTypeRef) where T<:LLVMType
ref==C_NULL && throw(NullException())
@static if DEBUG
@debug begin
Copy link

Choose a reason for hiding this comment

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

This seems like an odd use of @debug to contain an @assert.

Really @debug is for emitting verbose, low priority messages which may be ignored. The expression passed to @debug should evaluate to a human-readable message.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, I wanted to avoid (DRY) another global DEBUG setting that determines whether costly checks are enabled, and (ab)using @debug seemed like a prime candidate for that. I see now how it still prints something.

@maleadt
Copy link
Collaborator Author

maleadt commented Dec 15, 2017

Also, I didn't mean to ping you in order to get personalized comments; although I welcome them I'd be happy to wait until everything has settled a little 🙂

@c42f
Copy link

c42f commented Dec 16, 2017

No problems, thanks for pinging me - having a lot of diverse use cases is really important for designing the right thing here I think. I learned something reading the tricks you had to pull here to debug finalizer issues. Hopefully somehow addressable in Base, we'll see.

maleadt added a commit that referenced this pull request Feb 16, 2018
@maleadt maleadt closed this Feb 16, 2018
maleadt added a commit that referenced this pull request Mar 16, 2018
maleadt added a commit that referenced this pull request Mar 16, 2018
Use new logging infrastructure (supersede #78).
@maleadt maleadt deleted the tb/logging branch March 16, 2018 16:03
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.

2 participants