Skip to content

Commit 0fc8405

Browse files
committed
removing boxstr
1 parent 3669f9a commit 0fc8405

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Libxc = "0.3.17"
9696
LineSearches = "7"
9797
LinearAlgebra = "1"
9898
LinearMaps = "3"
99+
Logging = "1"
99100
LoopVectorization = "0.12"
100101
MPI = "0.20.13"
101102
Markdown = "1"

src/DFTK.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ include("workarounds/dummy_inplace_fft.jl")
231231
include("workarounds/forwarddiff_rules.jl")
232232
include("workarounds/gpu_arrays.jl")
233233

234+
function __init__()
235+
# We need to wait to have access to stdout.
236+
# But now local to the REPL…
237+
default_logger = DFTKLogger(; io=Base.stdout)
238+
global_logger(default_logger)
239+
end
240+
234241
# Precompilation block with a basic workflow
235242
@setup_workload begin
236243
# very artificial silicon ground state example

src/common/logging.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
using Logging
22

3+
# Removing most of format for `@info` in default logger.
34
function meta_formatter(level::LogLevel, args...)
45
color = Logging.default_logcolor(level)
56
Info == level && return color, "", ""
67
Logging.default_metafmt(level, args...)
78
end
8-
global_logger(ConsoleLogger(stdout, Info; meta_formatter))
9+
10+
# Bypasses everything to ConsoleLogger but Info which just shows message without any
11+
# formatting.
12+
Base.@kwdef struct DFTKLogger <: AbstractLogger
13+
io::IO
14+
min_level::LogLevel = Info
15+
fallback = ConsoleLogger(io, min_level; meta_formatter)
16+
end
17+
function Logging.handle_message(logger::DFTKLogger, level, msg, args...; kwargs...)
18+
level == Info && return level < logger.min_level ? nothing : println(logger.io, msg)
19+
Logging.handle_message(logger.fallback, level, msg, args...; kwargs...)
20+
end
21+
Logging.min_enabled_level(logger::DFTKLogger) = logger.min_level
22+
Logging.shouldlog(::DFTKLogger, args...) = true

src/common/threading.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function disable_threading()
1919
"JULIA_NUM_THREADS is unset and julia does not get the `-t` flag passed."
2020
)
2121
@assert n_julia == 1 # To exit in non-master MPI nodes
22-
setup_threading(;n_fft=1, n_blas=1)
22+
setup_threading(; n_fft=1, n_blas=1)
2323
end
2424

2525
# Parallelization loop breaking range into chunks.

test/runtests_runner.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ end
3232

3333
using Logging
3434

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

0 commit comments

Comments
 (0)