-
-
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
RFC: Base logging #24490
RFC: Base logging #24490
Conversation
base/distributed/cluster.jl
Outdated
@@ -1036,7 +1036,7 @@ function disable_nagle(sock) | |||
@static if Sys.islinux() | |||
# tcp_quickack is a linux only option | |||
if ccall(:jl_tcp_quickack, Cint, (Ptr{Void}, Cint), sock.handle, 1) < 0 | |||
warn_once("Networking unoptimized ( Error enabling TCP_QUICKACK : ", Libc.strerror(Libc.errno()), " )") | |||
@warn "Networking unoptimized ( Error enabling TCP_QUICKACK : $(Libc.strerror(Libc.errno())) )" |
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.
Missing max_log=1
?
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.
Good catch. You can tell this is one i hand edited :)
base/distributed/managers.jl
Outdated
end | ||
else | ||
# This state can happen immediately after an addprocs | ||
warn(STDERR,"worker $id cannot be presently interrupted.") | ||
@warn "Worker $id cannot be presently interrupted." |
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.
I guess arguably these two should be @error
What was wrong with functions? |
With macros several very useful things can be done which either aren't possible with functions or impose a syntax burden:
|
I need to review this more thoroughly, but from a quick perusal, I really like this. |
Great. Here's the deprecation plan for the current logging functions
|
As it turns out I'm not really happy with the log testing tools in To test that some code inside @test_logs (Info, "message") (Warn, "ohno") foo() The idea is that this will be sugar for something like @test logs_match((Info, "message"), (Warn, "ohno")) do
foo()
end Where the @test_logs LogPattern(Info, r"Failed at iteration [0-9]+", a=10) foo() |
base/deprecated.jl
Outdated
# #24490 | ||
# info() warn() and logging() are deprecated (see util.jl). When removing | ||
# these, the functions redirect() and _redirect() should also be removed, along | ||
# with log_info_to, log_warn_to and log_error_to. |
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.
A small question: is it ok to put this note here, or should the parts of util.jl
which are deprecated be explicitly moved? It's 200 lines of code or so which is why I left it in place for now.
@StefanKarpinski what's the chance of this making it into 0.7? I'd really like to see the effort I've put into this make it into 1.0. If not, compatibility in the 1.0 cycle technically dictates several more years of logs-as-text which I think would be a real pity when we're on the cusp of something far more powerful. At the moment I'm trying really hard to push through to the end with this and I'm rather close to making all the tests work - probably a day or two away. But if it's not worth the slog I'll think about giving myself a break! |
cc @tanmaykm |
I say let's go ahead with this! |
base/deprecated.jl
Outdated
_id=(frame,funcsym), | ||
_group=:depwarn, | ||
caller=caller, | ||
max_log=1 |
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.
We typically avoid underscores like this, so I think it'd be better to call this maxlog
.
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.
Yeah ok, let's do that. Updated now.
One comment: this is a significant number of new related exports from Base. How about wrapping the new functionality in a |
Functionality looks great. I'd rather not add 13 exports to Base for this. I think a stdlib psuedo-package would be the way to go here; the code can be in base but you do |
Oh yeah, using a stdlib package for the non-basic functionality is even better. Then it can evolve. |
Excellent! I'm totally on board with putting as much of this in a stdlib package as possible. What you see here has already had a fair bit of reduction and removal of several features which need more thought. (For instance, you'll see there's no mention of a log record data structure, collection of log records, functions for configuring the current logger, log formatting or filtering, etc.) The reason it's not reduced further is that it seems important for I'll have to think about how to move even more functionality over to a |
Another option would be to have Logging be a submodule of Base, i.e. |
Refactoring things to actually move code out of Base is fine if it's not too difficult, but that's not even necessary --- |
Thanks Jeff, I think that makes sense. I'm a little hazy on the subtleties though - it seems like there might be several things we'd like. What are we aiming for, primarily? Are we:
If we just need (1), I can make a skeleton package for now, and remove most or all of the exports from Regarding point (2) - I haven't looked closely but we seem to be missing some infrastructure for this at the moment. So I'm going to ignore it unless someone says otherwise. |
Right, that's why I suggested exporting
Create a stub
I'm not positive if this is the right split, but my thinking is that the simple logging macros are all that most code need to use basic logging, while the rest are mostly only needed to control logging, or in the case of |
Cool that's exactly the split which makes sense to me. I'll do the export tweaks as soon as I can scrape together a few hours. |
Awesome! There's more to do but that's the deprecations out of the way and we can proceed incrementally which will be a lot easier. It's a relief to not be maintaining this on a branch :-) |
Edit: Nevermind, it's just that the caller look really weird from the REPL. From a function:
|
Somehow you never really shake out all the bugs until you merge it 😁 |
Right, I'm waiting in trepidation! @fredrikekre is this a bug? Ah, I guess it's the |
Right, I probably just got scared of the output. Some kind of filtering would be nice for repl usage I guess, the printed internal functions there does not really help |
Is it expected that the deprecated methods don't use the new logging interface?
|
Filtering C functions (like the back trace printer seems like a good idea). |
I would expect them to continue to work the way they previously did. |
Right, I confused myself... 😄 |
Regarding deprecated behavior of Regarding colorization - we could print the entire message in color, but I think if we're not careful we end up with so much color on the screen that it's hard to focus on the parts which matter. I've also got another motive here: I'd like to render the message itself as markdown and this will involve a different competing colorization for parts of the message. This is already done by |
- info replaced by @info JuliaLang/julia#24490 -linspace has been deprecated in favor of range with stop and length keyword arguments (#25896). JuliaLang/julia#25896
- info replaced by @info JuliaLang/julia#24490 -linspace has been deprecated in favor of range with stop and length keyword arguments (#25896). JuliaLang/julia#25896
Here's the first part of #23712 cleaned up so that it's in a more digestible and less obviously broken form. There's basically two things here:
The core of MicroLogging (src/core.jl), very slightly tweaked.
Most of this arguably needs to be in
Base
because log messages from the rest ofBase
will be using the logging macros, and ideally messages from the parser and runtime C code will be dispatched to the logging system (see #23712 for partial implementation of these extensions). We may be able to move a little more of it to stdlib however - I anticipate a stdlibLogging
library with more general configuration and logging tools.Port of all Base logging from the function call style to logging macros
This second part was somewhat mechanical, assisted by a hacked version of Deprecations.jl. This is mostly a straight port, resisting the urge to use the new features in an attempt to avoid bugs (many of these messages are untested, I think.). Some things are edited for consistency:
exception=ex
TODO
There's still a few things to do (some copied from c42f/MicroLogging.jl#5)
test_warn
)test_warn
over to the new systemAbstractLogger
related functions, log level limits, etc. Some of these made more sense when scoped inside a package, but don't so much inBase
.info()
andwarn()
.