julia icon indicating copy to clipboard operation
julia copied to clipboard

ConsoleLogger not active in the REPL

Open fredrikekre opened this issue 2 years ago • 3 comments

Logging.__init__ replaces the global logger: https://github.com/JuliaLang/julia/blob/1327dfec807fa00782311f02d095b8e37ea55f2a/stdlib/Logging/src/Logging.jl#L93-L95 Before #51399 this was more or less impossible to notice since Logging.__init__ was run when loading the sysimg. However, now this isn't the case anymore. This means that

  1. The colorless SimpleLogger is used by default in the REPL
  2. using Logging replaces the logger, which might be a logger a user has already configured
julia> @info "Where are my colors?" logtype = typeof(Base.global_logger())
┌ Info: Where are my colors?
│   logtype = Base.CoreLogging.SimpleLogger
└ @ Main REPL[1]:1

julia> using Logging

julia> @info "Thanks for the colors, but you stole my logger..." logtype = typeof(Base.global_logger())
┌ Info: Thanks for the colors, but you stole my logger...
└   logtype = ConsoleLogger

image

Not sure what the best fix is, but probably REPL should depend on Logging and setup the logger while the REPL initializes.

fredrikekre avatar Nov 08 '23 10:11 fredrikekre

Maybe the cause of https://github.com/JuliaLang/JuliaSyntax.jl/issues/375

KristofferC avatar Nov 08 '23 13:11 KristofferC

It's a problem before REPL for startup.jl too https://github.com/JuliaLang/julia/issues/51493

IanButterworth avatar Nov 08 '23 15:11 IanButterworth

I was planning on moving ConsoleLogger to Base to fix this but it depends on StyledStrings now so that's not really possible.

KristofferC avatar Feb 14 '24 13:02 KristofferC