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

redirect_stderr() and redirect_stdout() do not control logging output #26798

Closed
ghost opened this issue Apr 13, 2018 · 5 comments · Fixed by #40423
Closed

redirect_stderr() and redirect_stdout() do not control logging output #26798

ghost opened this issue Apr 13, 2018 · 5 comments · Fixed by #40423
Labels
io Involving the I/O subsystem: libuv, read, write, etc. logging The logging framework

Comments

@ghost
Copy link

ghost commented Apr 13, 2018

redirect_stderr()
redirect_stdout()
@warn "should not be able to see it"

The output is

┌ Warning: should not be able to see it
└ @ Main t.jl:3

Expected no output.

@ghost
Copy link
Author

ghost commented Apr 13, 2018

And @info goes into stderr instead of expected stdout, not able to control it too.

@ghost
Copy link
Author

ghost commented Apr 13, 2018

Makes debugging harder, see timholy/Revise.jl#80

@JeffBezanson JeffBezanson added io Involving the I/O subsystem: libuv, read, write, etc. logging The logging framework labels Apr 13, 2018
@stevengj
Copy link
Member

I think the problem is that SimpleLogger (the default logger) stores stderr as its stream::IO member, so it keeps a reference to the original stderr stream even when the stderr global has been redirected.

@staticfloat
Copy link
Member

Not just SimpleLogger; ConsoleLogger does as well. @c42f what, in your opinion, is the best way to change streams out from underneath a logger? Should we destroy the current loggers and create new ones that point to the streams we like?

@maleadt
Copy link
Member

maleadt commented Jun 20, 2018

It's what we do in the atexit hook:

function __init__()
global_logger(ConsoleLogger(stderr))
atexit() do
logger = global_logger()
if isa(logger, ConsoleLogger)
global_logger(ConsoleLogger(Core.stderr, min_enabled_level(logger)))
end
end
end

vtjnash added a commit that referenced this issue Apr 9, 2021
This has the additional benefit of making the initial logger respect
changes to redirect_stderr/stdout, until the user explicitly sets
another stream as the logging destination.

Fix #26798
Fix #38482
Replaces #26920, which provided the idea and most of the implementation

Co-author-by: Joe Petviashvili <[email protected]>
vtjnash added a commit that referenced this issue Apr 9, 2021
This has the additional benefit of making the initial logger respect
changes to redirect_stderr/stdout, until the user explicitly sets
another stream as the logging destination.

Fix #26798
Fix #38482
Replaces #26920, which provided the idea and most of the implementation

Co-author-by: Joe Petviashvili <[email protected]>
vtjnash added a commit that referenced this issue Apr 9, 2021
This has the additional benefit of making the initial logger respect
changes to redirect_stderr/stdout, until the user explicitly sets
another stream as the logging destination.

Fix #26798
Fix #38482
Replaces #26920, which provided the idea and most of the implementation

Co-authored-by: Joe Petviashvili <[email protected]>
vtjnash added a commit that referenced this issue Apr 21, 2021
This has the additional benefit of making the initial logger respect
changes to redirect_stderr/stdout, until the user explicitly sets
another stream as the logging destination.

Fix #26798
Fix #38482
Replaces #26920, which provided the idea and most of the implementation

Co-authored-by: Joe Petviashvili <[email protected]>
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this issue May 4, 2021
This has the additional benefit of making the initial logger respect
changes to redirect_stderr/stdout, until the user explicitly sets
another stream as the logging destination.

Fix JuliaLang#26798
Fix JuliaLang#38482
Replaces JuliaLang#26920, which provided the idea and most of the implementation

Co-authored-by: Joe Petviashvili <[email protected]>
antoine-levitt pushed a commit to antoine-levitt/julia that referenced this issue May 9, 2021
This has the additional benefit of making the initial logger respect
changes to redirect_stderr/stdout, until the user explicitly sets
another stream as the logging destination.

Fix JuliaLang#26798
Fix JuliaLang#38482
Replaces JuliaLang#26920, which provided the idea and most of the implementation

Co-authored-by: Joe Petviashvili <[email protected]>
johanmon pushed a commit to johanmon/julia that referenced this issue Jul 5, 2021
This has the additional benefit of making the initial logger respect
changes to redirect_stderr/stdout, until the user explicitly sets
another stream as the logging destination.

Fix JuliaLang#26798
Fix JuliaLang#38482
Replaces JuliaLang#26920, which provided the idea and most of the implementation

Co-authored-by: Joe Petviashvili <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io Involving the I/O subsystem: libuv, read, write, etc. logging The logging framework
Projects
None yet
4 participants