-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Logging.disable_logging() either broken or docs not clear on usage #34037
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
Comments
So first of all to see the logs in realtime use ENV["JULIA_DEBUG"] = "all" julia> using Logging
julia> ENV["JULIA_DEBUG"] = "all"
"all"
julia> @debug "hello"
┌ Debug: hello
└ @ Main REPL[3]:1
julia> @info "hello"
[ Info: hello
julia> disable_logging(LogLevel(-1)) # **FOR INFO**
Info
julia> @info "hello"
[ Info: hello
julia> @debug "hello"
julia> disable_logging(LogLevel(-1001)) # **FOR DEBUG**
Debug
julia> @debug "hello"
┌ Debug: hello
└ @ Main REPL[9]:1
julia> @info "hello"
[ Info: hello hope this resolves your issue 😄 |
I see. So Instead of the docstring here:
Perhaps it's more accurate to say
I can PR if you agree? |
I have to say I do find that setup a bit inelegant/unclear |
`ENV["JULIA_DEBUG"] = "YourPackage" makes more sense Also, need a clear picture of how disable_logging() affects debug, info, warn and error |
I'm keen on this change @IanButterworth. It feels quite unclear to be unable to enable debug logging during development without resorting to environment variable changes, especially when it effectively means the
EDIT: Appreciate that brute forcing all modules to log debug might be a bit naff, so also happy to look at a PR, perhaps with some addition that allows registration of the necessary modules? A |
A clarifying note added to #57591 |
Closes JuliaLang#57376 Closes JuliaLang#34037 - Adds a lock in `SimpleLogger` and `ConsoleLogger` for use on maxlog tracking and stream writes to improve threadsafety. Closely similar to JuliaLang#54497 - Turns the internal `_min_enabled_level` into a `Threads.Atomic`. There are [some direct interactions](https://juliahub.com/ui/Search?type=code&q=_min_enabled_level&w=true) to this internal in the ecosystem, but they should still work ``` julia> Base.CoreLogging._min_enabled_level[] = Logging.Info+1 LogLevel(1) ``` - Brings tests over from JuliaLang#57448 Performance seems highly similar: ``` julia> @time for i in 1:10000 @info "foo" maxlog=10000000 end [ Info: foo ... 0.481446 seconds (1.33 M allocations: 89.226 MiB, 0.49% gc time) ``` ``` 0.477235 seconds (1.31 M allocations: 79.002 MiB, 1.77% gc time) ```
Closes #57376 Closes #34037 - Adds a lock in `SimpleLogger` and `ConsoleLogger` for use on maxlog tracking and stream writes to improve threadsafety. Closely similar to #54497 - Turns the internal `_min_enabled_level` into a `Threads.Atomic`. There are [some direct interactions](https://juliahub.com/ui/Search?type=code&q=_min_enabled_level&w=true) to this internal in the ecosystem, but they should still work ``` julia> Base.CoreLogging._min_enabled_level[] = Logging.Info+1 LogLevel(1) ``` - Brings tests over from #57448 Performance seems highly similar: ### Master ``` julia> @time for i in 1:10000 @info "foo" maxlog=10000000 end [ Info: foo ... 0.481446 seconds (1.33 M allocations: 89.226 MiB, 0.49% gc time) ``` ### This PR ``` 0.477235 seconds (1.31 M allocations: 79.002 MiB, 1.77% gc time) ``` (cherry picked from commit 9af9650)
From the docs on
disable_logging()
I believe this should be able to enable the debug logging. Either it's broken or the docs aren't clear on correct usageThe text was updated successfully, but these errors were encountered: