Skip to content

Commit

Permalink
always send log messages to stderr by default (#41653)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfitzseb authored Jul 20, 2021
1 parent d26dc9e commit e196b85
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
2 changes: 1 addition & 1 deletion base/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ function handle_message(logger::SimpleLogger, level::LogLevel, message, _module,
buf = IOBuffer()
stream = logger.stream
if !isopen(stream)
stream = level < Warn ? stdout : stderr
stream = stderr
end
iob = IOContext(buf, stream)
levelstr = level == Warn ? "Warning" : string(level)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Logging/src/ConsoleLogger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
msglines = [(indent=0, msg=l) for l in split(chomp(string(message)::String), '\n')]
stream = logger.stream
if !isopen(stream)
stream = level < Warn ? stdout : stderr
stream = stderr
end
dsize = displaysize(stream)::Tuple{Int,Int}
nkwargs = length(kwargs)::Int
Expand Down
16 changes: 1 addition & 15 deletions test/corelogging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,20 +341,6 @@ end
String(take!(io))
end

function genmsg_out(level, message, _module, filepath, line; kws...)
fname = tempname()
f = open(fname, "w")
logger = SimpleLogger()
redirect_stdout(f) do
handle_message(logger, level, message, _module, :group, :id,
filepath, line; kws...)
end
close(f)
buf = read(fname)
rm(fname)
String(buf)
end

function genmsg_err(level, message, _module, filepath, line; kws...)
fname = tempname()
f = open(fname, "w")
Expand All @@ -370,7 +356,7 @@ end
end

# Simple
@test genmsg_out(Info, "msg", Main, "some/path.jl", 101) ==
@test genmsg_err(Info, "msg", Main, "some/path.jl", 101) ==
"""
┌ Info: msg
└ @ Main some/path.jl:101
Expand Down

0 comments on commit e196b85

Please sign in to comment.