JuliaLogging / TerminalLoggers.jl

Logging sinks and utilites for interactive terminals
MIT License
41 stars 10 forks source link

Logging lazy strings with unicode characters errors #50

Open lassepe opened 1 month ago

lassepe commented 1 month ago

MWE:

using TerminalLoggers, Logging
with_logger(TerminalLogger()) do
    @warn lazy"σ"
end

throws

ERROR: MethodError: no method matching IOBuffer(::LazyString)
The type `IOBuffer` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  IOBuffer(::SubString{String})
   @ Base strings/io.jl:309
  IOBuffer(::String)
   @ Base strings/io.jl:308
  IOBuffer(; read, write, append, truncate, maxsize, sizehint)
   @ Base iobuffer.jl:119
  ...

Stacktrace:
  [1] parse(markdown::LazyString; flavor::Markdown.Config)
    @ Markdown ~/.julia/juliaup/julia-1.11.0-rc3+0.x64.linux.gnu/share/julia/stdlib/v1.11/Markdown/src/Markdown.jl:35
  [2] format_message(message::LazyString, prefix_width::Int64, io_context::IOContext{Base.TTY})
    @ TerminalLoggers ~/.julia/packages/TerminalLoggers/FYGc9/src/TerminalLogger.jl:125
  [3] handle_message(logger::TerminalLogger, level::Base.CoreLogging.LogLevel, message::LazyString, _module::Module, group::Symbol, id::Symbol, filepath::String, line::Int64; maxlog::Nothing, sticky::Nothing, kwargs::@Kwargs{})
    @ TerminalLoggers ~/.julia/packages/TerminalLoggers/FYGc9/src/TerminalLogger.jl:309
  [4]
    @ TerminalLoggers ~/.julia/packages/TerminalLoggers/FYGc9/src/TerminalLogger.jl:284
  [5] #invokelatest#2
    @ ./essentials.jl:1054 [inlined]
  [6] invokelatest
    @ ./essentials.jl:1051 [inlined]
  [7] macro expansion
    @ ./logging/logging.jl:388 [inlined]
  [8] (::var"#1#2")()
    @ Main ./REPL[4]:2
  [9] with_logstate(f::var"#1#2", logstate::Base.CoreLogging.LogState)
    @ Base.CoreLogging ./logging/logging.jl:522
 [10] with_logger(f::Function, logger::TerminalLogger)
    @ Base.CoreLogging ./logging/logging.jl:632
 [11] top-level scope
    @ REPL[4]:1
Some type information was truncated. Use `show(err)` to see complete types.