-
Notifications
You must be signed in to change notification settings - Fork 158
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
[FR] allow disabling of logging #255
Comments
As an alternative, an environment variable to set verbosity would be nice, since then we can disable logging that happens before the package is fully loaded. |
So, is the suggestion something like this: In MLJBase.jl: BASE_VERBOSITY[] = Ref(1)
abs_verbosity(verbosity) = BASE_VERBOSITY + verbosity - 1
_integer(v::Integer) = v
_integer(s::String) = parse(Int, s)
set_verbosity(verbosity) = (BASE_VERBOSITY[] = _integer(verbosity))
...
function __init__()
...
set_verbosity(ENV["MLJ_VERBOSITY"])
...
end And we replace every test in MLJBase/MLJModels/MLJ of the form "if verbosity ..." with "if abs_verbosity(verbosity) ...", and so forth? |
Sounds good though the replace every test does not seem necessary? I was thinking we have |
Since all our logging is generated with Also, rather than adjusting a BASE_LEVEL, I agree it is conceptually simpler to just turn all logging on or off. The simplest thing is to manipulate julia's logging globally. I think this would be fine, and the entire implementation, including looking at env variable, is: import Logging
silent() = Loging.disable_logging(Logging.Warn)
loud() = Logging.disable_loggin(Loggin.Debug)
...
function __init__()
...
if haskey(ENV, "MLJ_SILENT") && parse(Bool, ENV["MLJ_SILENT"])
silent()
else
loud()
end
...
end
... That's it. |
Wouldn't that prevent users from using Logging themselves? |
This would indeed switch all logging off, not just the MLJ logging. |
Does anyone know how to control the logging of just one package? |
probably best to ask that on Discourse? |
In view of the post above, it seems to me that controlling logging is more the user's responsibility than the package's. Any activity he wants different logging levels for, he can just wrap appropriately. @tlienart Do you think we could close this? |
I’m a bit confused though, my initial question was to enable log surpression for the whole of MLJ in one function call; IMO this could be achieved by only logging if a toggle is on and then indeed when the logging is on, the user could additionally reduce it or whatever But it would be good to have the possibility to not log anything |
Using MLJ generates a bunch of statements like
I've executing everything after a
Logging.disable_logging(Logging.LogLevel(3_000))
but this did not have the intended effect (though possibly it had the intended effect for MLJ just not for MLJModels or something along those lines)Would it be possible to expose a function which switches all of this off? like a
set_verbosity(0)
?The text was updated successfully, but these errors were encountered: