Skip to content

Commit

Permalink
Fixed debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
JTHesse committed Jul 8, 2024
1 parent 875d9a4 commit 35d67a5
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 37 deletions.
43 changes: 34 additions & 9 deletions src/IO/IO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ Initialize write results.
- `outputs::Dict`: The outputs
"""
function init_write_results(params::Dict, output_dir::String, path::String, datamanager::Module, nsteps::Int64, PERILAB_VERSION::String)
global output_frequency

filenames = get_output_filenames(params, output_dir)
if length(filenames) == 0
@warn "No output file or output defined"
Expand Down Expand Up @@ -405,7 +407,6 @@ function init_write_results(params::Dict, output_dir::String, path::String, data

coords = vcat(transpose(coordinates[1:nnodes, :]))
output_frequencies = get_output_frequency(params, nsteps)
global output_frequency = []
for id in eachindex(result_files)

if result_files[id]["type"] == "Exodus"
Expand Down Expand Up @@ -635,17 +636,29 @@ function show_block_summary(solver_options::Dict, params::Dict, log_file::String
end
if !silent
pretty_table(full_df; show_subheader=false)
pretty_table(current_logger().loggers[2].logger.stream, full_df; show_subheader=false)
stream = Logging_module.get_log_stream(2)
if !isnothing(stream)
pretty_table(stream, full_df; show_subheader=false)
end
else
pretty_table(current_logger().loggers[1].logger.stream, full_df; show_subheader=false)
stream = Logging_module.get_log_stream(1)
if !isnothing(stream)
pretty_table(stream, full_df; show_subheader=false)
end
end
else
if log_file != ""
if !silent
pretty_table(df; show_subheader=false)
pretty_table(current_logger().loggers[2].logger.stream, df; show_subheader=false)
stream = Logging_module.get_log_stream(2)
if !isnothing(stream)
pretty_table(stream, df; show_subheader=false)
end
else
pretty_table(current_logger().loggers[1].logger.stream, df; show_subheader=false)
stream = Logging_module.get_log_stream(1)
if !isnothing(stream)
pretty_table(stream, df; show_subheader=false)
end
end
end
end
Expand Down Expand Up @@ -705,17 +718,29 @@ function show_mpi_summary(log_file::String, silent::Bool, comm::MPI.Comm, datama
merged_df = vcat(all_dfs...)
if !silent
pretty_table(merged_df; show_subheader=false)
pretty_table(current_logger().loggers[2].logger.stream, merged_df; show_subheader=false)
stream = Logging_module.get_log_stream(2)
if !isnothing(stream)
pretty_table(stream, merged_df; show_subheader=false)
end
else
pretty_table(current_logger().loggers[1].logger.stream, merged_df; show_subheader=false)
stream = Logging_module.get_log_stream(1)
if !isnothing(stream)
pretty_table(stream, merged_df; show_subheader=false)
end
end
else
if log_file != ""
if !silent
pretty_table(df; show_subheader=false)
pretty_table(current_logger().loggers[2].logger.stream, df; show_subheader=false)
stream = Logging_module.get_log_stream(2)
if !isnothing(stream)
pretty_table(stream, df; show_subheader=false)
end
else
pretty_table(current_logger().loggers[1].logger.stream, df; show_subheader=false)
stream = Logging_module.get_log_stream(1)
if !isnothing(stream)
pretty_table(stream, df; show_subheader=false)
end
end
end
end
Expand Down
70 changes: 42 additions & 28 deletions src/IO/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using Dates
export init_logging
export set_result_files
export get_current_git_info
export get_log_stream

result_files::Vector{Dict} = []
log_file::String = ""
Expand Down Expand Up @@ -55,6 +56,13 @@ function get_log_file()
return log_file
end

function get_log_stream(id::Int64)
try
return current_logger().loggers[id].logger.stream
catch
return nothing
end
end
"""
set_result_files(result_files_temp::Vector{Dict})
Expand Down Expand Up @@ -121,35 +129,41 @@ function print_table(data::Matrix, datamanager::Module)
show_header=false,
tf=tf_borderless
)
pretty_table(
current_logger().loggers[2].logger.stream,
data;
body_hlines=[1],
body_hlines_format=Tuple('' for _ = 1:4),
cell_alignment=Dict((1, 1) => :l),
formatters=ft_printf("%10.1f", 2),
highlighters=(
hl_cell([(1, 1)], crayon"bold"),
hl_col(2, crayon"dark_gray")
),
show_header=false,
tf=tf_borderless
)
stream = Logging_module.get_log_stream(2)
if !isnothing(stream)
pretty_table(
stream,
data;
body_hlines=[1],
body_hlines_format=Tuple('' for _ = 1:4),
cell_alignment=Dict((1, 1) => :l),
formatters=ft_printf("%10.1f", 2),
highlighters=(
hl_cell([(1, 1)], crayon"bold"),
hl_col(2, crayon"dark_gray")
),
show_header=false,
tf=tf_borderless
)
end
else
pretty_table(
current_logger().loggers[1].logger.stream,
data;
body_hlines=[1],
body_hlines_format=Tuple('' for _ = 1:4),
cell_alignment=Dict((1, 1) => :l),
formatters=ft_printf("%10.1f", 2),
highlighters=(
hl_cell([(1, 1)], crayon"bold"),
hl_col(2, crayon"dark_gray")
),
show_header=false,
tf=tf_borderless
)
stream = Logging_module.get_log_stream(1)
if !isnothing(stream)
pretty_table(
stream,
data;
body_hlines=[1],
body_hlines_format=Tuple('' for _ = 1:4),
cell_alignment=Dict((1, 1) => :l),
formatters=ft_printf("%10.1f", 2),
highlighters=(
hl_cell([(1, 1)], crayon"bold"),
hl_col(2, crayon"dark_gray")
),
show_header=false,
tf=tf_borderless
)
end
end
end

Expand Down

0 comments on commit 35d67a5

Please sign in to comment.