Skip to content

Commit

Permalink
removing boxstr
Browse files Browse the repository at this point in the history
  • Loading branch information
epolack committed Feb 26, 2024
1 parent 3f14fa3 commit 2353ffc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Libxc = "0.3.17"
LineSearches = "7"
LinearAlgebra = "1"
LinearMaps = "3"
Logging = "1"
LoopVectorization = "0.12"
MPI = "0.20.13"
Markdown = "1"
Expand Down
7 changes: 7 additions & 0 deletions src/DFTK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ include("workarounds/dummy_inplace_fft.jl")
include("workarounds/forwarddiff_rules.jl")
include("workarounds/gpu_arrays.jl")

function __init__()
# We need to wait to have access to stdout.
# But now local to the REPL…
default_logger = DFTKLogger(; io=Base.stdout)
global_logger(default_logger)
end

# Precompilation block with a basic workflow
@setup_workload begin
# very artificial silicon ground state example
Expand Down
16 changes: 15 additions & 1 deletion src/common/logging.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
using Logging

# Removing most of format for `@info` in default logger.
function meta_formatter(level::LogLevel, args...)
color = Logging.default_logcolor(level)
Info == level && return color, "", ""
Logging.default_metafmt(level, args...)
end
global_logger(ConsoleLogger(stdout, Info; meta_formatter))

# Bypasses everything to ConsoleLogger but Info which just shows message without any
# formatting.
Base.@kwdef struct DFTKLogger <: AbstractLogger
io::IO
min_level::LogLevel = Info
fallback = ConsoleLogger(io, min_level; meta_formatter)
end
function Logging.handle_message(logger::DFTKLogger, level, msg, args...; kwargs...)
level == Info && return level < logger.min_level ? nothing : println(logger.io, msg)
Logging.handle_message(logger.fallback, level, msg, args...; kwargs...)
end
Logging.min_enabled_level(logger::DFTKLogger) = logger.min_level
Logging.shouldlog(::DFTKLogger, args...) = true
2 changes: 1 addition & 1 deletion src/common/threading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function disable_threading()
"JULIA_NUM_THREADS is unset and julia does not get the `-t` flag passed."
)
@assert n_julia == 1 # To exit in non-master MPI nodes
setup_threading(;n_fft=1, n_blas=1)
setup_threading(; n_fft=1, n_blas=1)
end

# Parallelization loop breaking range into chunks.
Expand Down
3 changes: 2 additions & 1 deletion test/runtests_runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ end

using Logging

with_logger(ConsoleLogger(stdout, LogLevel(1))) do
# Don't print anything below or equal to warning level.
with_logger(ConsoleLogger(stdout, LogLevel(1001))) do
@run_package_tests filter=dftk_testfilter verbose=true
end

0 comments on commit 2353ffc

Please sign in to comment.