From 6c53d82779dd4aa69b7e2ad2d06c48757afbe80b Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Sun, 10 Nov 2019 20:23:26 +0000 Subject: [PATCH] Use extended brackets instead of box-drawing characters in log messages --- base/logging.jl | 8 +- stdlib/Logging/docs/src/index.md | 32 +++---- stdlib/Logging/src/ConsoleLogger.jl | 6 +- stdlib/Logging/test/runtests.jl | 138 ++++++++++++++-------------- test/cmdlineargs.jl | 2 +- test/logging.jl | 22 ++--- 6 files changed, 104 insertions(+), 104 deletions(-) diff --git a/base/logging.jl b/base/logging.jl index 0de8ae9337374..fa7c2d072788f 100644 --- a/base/logging.jl +++ b/base/logging.jl @@ -544,14 +544,14 @@ function handle_message(logger::SimpleLogger, level, message, _module, group, id iob = IOContext(buf, logger.stream) levelstr = level == Warn ? "Warning" : string(level) msglines = split(chomp(string(message)), '\n') - println(iob, "┌ ", levelstr, ": ", msglines[1]) + println(iob, "⎡ ", levelstr, ": ", msglines[1]) for i in 2:length(msglines) - println(iob, "│ ", msglines[i]) + println(iob, "⎜ ", msglines[i]) end for (key, val) in kwargs - println(iob, "│ ", key, " = ", val) + println(iob, "⎜ ", key, " = ", val) end - println(iob, "└ @ ", something(_module, "nothing"), " ", + println(iob, "⎣ @ ", something(_module, "nothing"), " ", something(filepath, "nothing"), ":", something(line, "nothing")) write(logger.stream, take!(buf)) nothing diff --git a/stdlib/Logging/docs/src/index.md b/stdlib/Logging/docs/src/index.md index c481733fcf60a..cffaee41cca7c 100644 --- a/stdlib/Logging/docs/src/index.md +++ b/stdlib/Logging/docs/src/index.md @@ -6,8 +6,8 @@ statement into the source code, for example: ```julia @warn "Abandon printf debugging, all ye who enter here!" -┌ Warning: Abandon printf debugging, all ye who enter here! -└ @ Main REPL[1]:1 +⎡ Warning: Abandon printf debugging, all ye who enter here! +⎣ @ Main REPL[1]:1 ``` The system provides several advantages over peppering your source code with @@ -36,14 +36,14 @@ v = ones(100) @info "Some variables" A s=sum(v) # output -┌ Info: Some variables -│ A = -│ 4×4 Array{Int64,2}: -│ 1 1 1 1 -│ 1 1 1 1 -│ 1 1 1 1 -│ 1 1 1 1 -└ s = 100.0 +⎡ Info: Some variables +⎜ A = +⎜ 4×4 Array{Int64,2}: +⎜ 1 1 1 1 +⎜ 1 1 1 1 +⎜ 1 1 1 1 +⎜ 1 1 1 1 +⎣ s = 100.0 ``` All of the logging macros `@debug`, `@info`, `@warn` and `@error` share common @@ -186,11 +186,11 @@ module. For example, loading julia with `JULIA_DEBUG=loading` will activate ``` $ JULIA_DEBUG=loading julia -e 'using OhMyREPL' -┌ Debug: Rejecting cache file /home/user/.julia/compiled/v0.7/OhMyREPL.ji due to it containing an invalid cache header -└ @ Base loading.jl:1328 +⎡ Debug: Rejecting cache file /home/user/.julia/compiled/v0.7/OhMyREPL.ji due to it containing an invalid cache header +⎣ @ Base loading.jl:1328 [ Info: Recompiling stale cache file /home/user/.julia/compiled/v0.7/OhMyREPL.ji for module OhMyREPL -┌ Debug: Rejecting cache file /home/user/.julia/compiled/v0.7/Tokenize.ji due to it containing an invalid cache header -└ @ Base loading.jl:1328 +⎡ Debug: Rejecting cache file /home/user/.julia/compiled/v0.7/Tokenize.ji due to it containing an invalid cache header +⎣ @ Base loading.jl:1328 ... ``` @@ -211,8 +211,8 @@ julia> ENV["JULIA_DEBUG"] = Main Main julia> foo() -┌ Debug: foo -└ @ Main REPL[1]:1 +⎡ Debug: foo +⎣ @ Main REPL[1]:1 ``` diff --git a/stdlib/Logging/src/ConsoleLogger.jl b/stdlib/Logging/src/ConsoleLogger.jl index 4de55f05ca99a..5c35a70b105bb 100644 --- a/stdlib/Logging/src/ConsoleLogger.jl +++ b/stdlib/Logging/src/ConsoleLogger.jl @@ -142,9 +142,9 @@ function handle_message(logger::ConsoleLogger, level, message, _module, group, i end for (i,(indent,msg)) in enumerate(msglines) boxstr = length(msglines) == 1 ? "[ " : - i == 1 ? "┌ " : - i < length(msglines) ? "│ " : - "└ " + i == 1 ? "⎡ " : + i < length(msglines) ? "⎜ " : + "⎣ " printstyled(iob, boxstr, bold=true, color=color) if i == 1 && !isempty(prefix) printstyled(iob, prefix, " ", bold=true, color=color) diff --git a/stdlib/Logging/test/runtests.jl b/stdlib/Logging/test/runtests.jl index fb4f6d6197b35..81d9cad512aaa 100644 --- a/stdlib/Logging/test/runtests.jl +++ b/stdlib/Logging/test/runtests.jl @@ -98,29 +98,29 @@ end @test genmsg("line1\nline2", level=Logging.Warn, _module=Base, file="other.jl", line=42, meta_formatter=Logging.default_metafmt) == """ - ┌ Warning: line1 - │ line2 - └ @ Base other.jl:42 + ⎡ Warning: line1 + ⎜ line2 + ⎣ @ Base other.jl:42 """ # Full metadata formatting @test genmsg("msg", level=Logging.Debug, meta_formatter=(level, _module, group, id, file, line)-> (:white,"Foo!", "$level $_module $group $id $file $line")) == """ - ┌ Foo! msg - └ Debug Main a_group an_id some/path.jl 101 + ⎡ Foo! msg + ⎣ Debug Main a_group an_id some/path.jl 101 """ @testset "Prefix and suffix layout" begin @test genmsg("") == replace(""" - ┌ PREFIX EOL - └ SUFFIX + ⎡ PREFIX EOL + ⎣ SUFFIX """, "EOL"=>"") @test genmsg("msg") == """ - ┌ PREFIX msg - └ SUFFIX + ⎡ PREFIX msg + ⎣ SUFFIX """ # Behavior with empty prefix / suffix @test genmsg("msg", meta_formatter=(args...)->(:white, "PREFIX", "")) == @@ -129,8 +129,8 @@ end """ @test genmsg("msg", meta_formatter=(args...)->(:white, "", "SUFFIX")) == """ - ┌ msg - └ SUFFIX + ⎡ msg + ⎣ SUFFIX """ end @@ -141,29 +141,29 @@ end """ @test genmsg("xxx\nxxx", width=20, right_justify=200) == """ - ┌ PREFIX xxx - └ xxx SUFFIX + ⎡ PREFIX xxx + ⎣ xxx SUFFIX """ # When adding the suffix would overflow the display width, add it on # the next line: @test genmsg("xxxx", width=20, right_justify=200) == """ - ┌ PREFIX xxxx - └ SUFFIX + ⎡ PREFIX xxxx + ⎣ SUFFIX """ # Same for multiline messages @test genmsg("""xxx xxxxxxxxxx""", width=20, right_justify=200) == """ - ┌ PREFIX xxx - └ xxxxxxxxxx SUFFIX + ⎡ PREFIX xxx + ⎣ xxxxxxxxxx SUFFIX """ @test genmsg("""xxx xxxxxxxxxxx""", width=20, right_justify=200) == """ - ┌ PREFIX xxx - │ xxxxxxxxxxx - └ SUFFIX + ⎡ PREFIX xxx + ⎜ xxxxxxxxxxx + ⎣ SUFFIX """ # min(right_justify,width) is used @test genmsg("xxx", width=200, right_justify=20) == @@ -172,86 +172,86 @@ end """ @test genmsg("xxxx", width=200, right_justify=20) == """ - ┌ PREFIX xxxx - └ SUFFIX + ⎡ PREFIX xxxx + ⎣ SUFFIX """ end # Keywords @test genmsg("msg", a=1, b="asdf") == """ - ┌ PREFIX msg - │ a = 1 - │ b = "asdf" - └ SUFFIX + ⎡ PREFIX msg + ⎜ a = 1 + ⎜ b = "asdf" + ⎣ SUFFIX """ # Exceptions shown with showerror @test genmsg("msg", exception=DivideError()) == """ - ┌ PREFIX msg - │ exception = DivideError: integer division error - └ SUFFIX + ⎡ PREFIX msg + ⎜ exception = DivideError: integer division error + ⎣ SUFFIX """ # Attaching backtraces bt = func1() @test startswith(genmsg("msg", exception=(DivideError(),bt)), """ - ┌ PREFIX msg - │ exception = - │ DivideError: integer division error - │ Stacktrace: - │ [1] func1() at""") + ⎡ PREFIX msg + ⎜ exception = + ⎜ DivideError: integer division error + ⎜ Stacktrace: + ⎜ [1] func1() at""") @testset "Limiting large data structures" begin @test genmsg("msg", a=fill(1.00001, 100,100), b=fill(2.00002, 10,10)) == replace(""" - ┌ PREFIX msg - │ a = - │ 100×100 Array{Float64,2}: - │ 1.00001 1.00001 1.00001 1.00001 … 1.00001 1.00001 1.00001 - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ ⋮ ⋱ EOL - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ b = - │ 10×10 Array{Float64,2}: - │ 2.00002 2.00002 2.00002 2.00002 … 2.00002 2.00002 2.00002 - │ 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 - │ 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 - │ ⋮ ⋱ EOL - │ 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 - │ 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 - └ SUFFIX + ⎡ PREFIX msg + ⎜ a = + ⎜ 100×100 Array{Float64,2}: + ⎜ 1.00001 1.00001 1.00001 1.00001 … 1.00001 1.00001 1.00001 + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ ⋮ ⋱ EOL + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ b = + ⎜ 10×10 Array{Float64,2}: + ⎜ 2.00002 2.00002 2.00002 2.00002 … 2.00002 2.00002 2.00002 + ⎜ 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 + ⎜ 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 + ⎜ ⋮ ⋱ EOL + ⎜ 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 + ⎜ 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 2.00002 + ⎣ SUFFIX """, "EOL"=>"") # EOL hack to work around git whitespace errors # Limiting the amount which is printed @test genmsg("msg", a=fill(1.00001, 10,10), show_limited=false) == """ - ┌ PREFIX msg - │ a = - │ 10×10 Array{Float64,2}: - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - │ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 - └ SUFFIX + ⎡ PREFIX msg + ⎜ a = + ⎜ 10×10 Array{Float64,2}: + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎜ 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 + ⎣ SUFFIX """ end # Basic colorization test @test genmsg("line1\nline2", color=true) == """ - \e[36m\e[1m┌ \e[22m\e[39m\e[36m\e[1mPREFIX \e[22m\e[39mline1 - \e[36m\e[1m│ \e[22m\e[39mline2 - \e[36m\e[1m└ \e[22m\e[39m\e[90mSUFFIX\e[39m + \e[36m\e[1m⎡ \e[22m\e[39m\e[36m\e[1mPREFIX \e[22m\e[39mline1 + \e[36m\e[1m⎜ \e[22m\e[39mline2 + \e[36m\e[1m⎣ \e[22m\e[39m\e[90mSUFFIX\e[39m """ end diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index b9769b74bcbf2..3a3cf0797bf36 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -67,7 +67,7 @@ let exename = `$(Base.julia_cmd()) --startup-file=no` # make sure this is a non-fatal error and the REPL still loads @test v[1] @test isempty(v[2]) - @test startswith(v[3], "┌ Warning: Failed to import InteractiveUtils into module Main\n") + @test startswith(v[3], "⎡ Warning: Failed to import InteractiveUtils into module Main\n") end real_threads = string(ccall(:jl_cpu_threads, Int32, ())) for nc in ("0", "-2", "x", "2x", " ", "") diff --git a/test/logging.jl b/test/logging.jl index 3bb8f083e4436..4c1d199520375 100644 --- a/test/logging.jl +++ b/test/logging.jl @@ -327,32 +327,32 @@ end # Simple @test genmsg(Info, "msg", Main, "some/path.jl", 101) == """ - ┌ Info: msg - └ @ Main some/path.jl:101 + ⎡ Info: msg + ⎣ @ Main some/path.jl:101 """ # Multiline message @test genmsg(Warn, "line1\nline2", Main, "some/path.jl", 101) == """ - ┌ Warning: line1 - │ line2 - └ @ Main some/path.jl:101 + ⎡ Warning: line1 + ⎜ line2 + ⎣ @ Main some/path.jl:101 """ # Keywords @test genmsg(Error, "msg", Base, "other.jl", 101, a=1, b="asdf") == """ - ┌ Error: msg - │ a = 1 - │ b = asdf - └ @ Base other.jl:101 + ⎡ Error: msg + ⎜ a = 1 + ⎜ b = asdf + ⎣ @ Base other.jl:101 """ # nothing values @test genmsg(Warn, "msg", nothing, nothing, nothing) == """ - ┌ Warning: msg - └ @ nothing nothing:nothing + ⎡ Warning: msg + ⎣ @ nothing nothing:nothing """ end