Make logs more colorful

This commit is contained in:
2021-05-27 18:01:32 -05:00
parent 99975db5cd
commit 3bd8428322
2 changed files with 18 additions and 1 deletions

View File

@@ -35,8 +35,17 @@ function handle_message(logger::TimeLogger,
kwargs...)
elapsed_time = time() - logger.initial_time
time_string = @sprintf("[%12.3f] ", elapsed_time)
if level >= Logging.Error
color = :light_red
elseif level >= Logging.Warn
color = :light_yellow
else
color = :light_green
end
if level >= logger.screen_log_level
print(time_string)
printstyled(time_string, color=color)
println(message)
end
if logger.file !== nothing && level >= logger.io_log_level
@@ -47,4 +56,9 @@ function handle_message(logger::TimeLogger,
end
end
function setup_logger()
initial_time = time()
global_logger(TimeLogger(initial_time=initial_time))
end
export TimeLogger

View File

@@ -3,6 +3,9 @@
# Released under the modified BSD license. See COPYING.md for more details.
using Test
using UnitCommitment
UnitCommitment.setup_logger()
@testset "UnitCommitment" begin
include("instance_test.jl")