-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
33 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
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 | ||
#using Preferences | ||
|
||
# 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) | ||
fallback = ConsoleLogger(io, min_level) | ||
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 | ||
|
||
# Minimum log level is read from LocalPreferences.toml; defaults to Info. | ||
#min_level = @load_preference("min_log_level"; default="0") | ||
default_logger() = DFTKLogger(; io=stdout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters