-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce logger type, remove module methods
- Loading branch information
1 parent
aa274c1
commit e344e11
Showing
8 changed files
with
278 additions
and
176 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" | ||
AbstractThermodynamicsLogger | ||
A Thermodynamics logger can be passed to | ||
thermo state constructors that (may) perform | ||
saturation adjustment. This logger will statically | ||
decide if a warning statement is printed, or | ||
if the function should error on non-convergence. | ||
""" | ||
abstract type AbstractThermodynamicsLogger end | ||
const ATL = AbstractThermodynamicsLogger | ||
|
||
""" | ||
WarningLogger | ||
Warn when saturation adjustment did not converge. | ||
""" | ||
struct WarningLogger <: AbstractThermodynamicsLogger end | ||
|
||
""" | ||
ErrorLogger | ||
Error (but do not warn) when saturation adjustment | ||
did not converge. | ||
This is really only useful in our development docs. | ||
""" | ||
struct ErrorLogger <: AbstractThermodynamicsLogger end | ||
|
||
""" | ||
WarnAndErrorLogger | ||
Warn and error (default) when saturation adjustment did not converge. | ||
""" | ||
struct WarnAndErrorLogger <: AbstractThermodynamicsLogger end | ||
|
||
""" | ||
VerboseLogger | ||
A verbose logger, for when we use RootSolvers `VerboseSolution` type. | ||
""" | ||
struct VerboseLogger{L} <: AbstractThermodynamicsLogger | ||
logger::L | ||
end | ||
|
||
""" | ||
NullLogger | ||
Do nothing when saturation adjustment did not converge. | ||
""" | ||
struct NullLogger <: AbstractThermodynamicsLogger end | ||
|
||
warn_msg(::WarningLogger) = true | ||
warn_msg(::WarnAndErrorLogger) = true | ||
warn_msg(l::VerboseLogger) = warn_msg(l.logger) | ||
warn_msg(::AbstractThermodynamicsLogger) = false | ||
|
||
error_msg(::ErrorLogger) = true | ||
error_msg(::WarnAndErrorLogger) = true | ||
error_msg(l::VerboseLogger) = error_msg(l.logger) | ||
error_msg(::AbstractThermodynamicsLogger) = false | ||
|
||
Base.broadcastable(x::AbstractThermodynamicsLogger) = tuple(x) |
Oops, something went wrong.